Download as pdf or txt
Download as pdf or txt
You are on page 1of 201

INTRODUCTION

• V7+ principles
• Legacy code transition
How can we manage the transition?
Native mode, Read-only pages, Classic pages, Hybrid mode

The dictionaries are no more the same


– Class / Representation vs Objects / Windows / Screens
– Some tools are also available and use the same metadata than previously: requests,
statistical inquiries.

4 options:
- Full V7: the transition has been done
- Read-only mode: class and representation for display, switch to classic page for
modification
- Classic page: V6 pages emulation
- Hybrid mode: V6 UI using

Today, we will work on full GV7 technology only

Version 7 technology – training 2


The Version 7 web UI
Web navigation principles
Every page has an URL
[Server URL : Service ] : syracuse-main/html/main.html?url=xxx

xxx is on of the following:


 /sdata/x3/FOLDER/[class]?REPRESENTATION=[class].$[facet]
 /trans/x3/FOLDER/$sessions?f=FUNCTION
 /sdata/syracuse/collaboration/[class]?REPRESENTATION=[class].$[facet]

The main segments are:


– The application/contract (sdata with 2 branches (syracuse or x3), or
trans for the classic pages)
– The endpoint (collaboration or the X3 FOLDER )
– A function or a class and a representation with additional
parameters
Version 7 technology – training 3
Platform administration

Managed by Version 7 Web platform


- Runs with node.js server
- Stores data in mongodb database

Defines:
- The user identification and connection
- The connection to the X3 servers
- The managements of access rights

Allows:
- To administrate additional resources (search index)
- To share documents (collaboration)
Version 7 technology – training 4
Implementation done
Separation between UI and business logic

Main dictionary items that will change in v7+


– Classes and Representations
– CRUD operation support (supervisor)

REPRESENTATION CLASSES TABLES

User Interface Business


Logic Data
Persistence

The classes are data structure with methods and operations: only the
business logic has to be implemented here
The representations are also classes, but dedicated to UI rules
The class will become a child class of the representation
Version 7 technology – training 5
Implementation done
The limits

Some advanced concepts exist in the « object » development


– Inheritence
– Multiple Inheritence
– Interfaces
– Abstract or Virtual Classes
– Polymorphism and Method Overriding
– different subclasses may implement a given method differently
– Encapsulation
– hiding the implementation details

These concepts might be useful but they introduce complexity


They are not implemented in the v7.0 framework
Version 7 technology – training 6
LANGUAGE EVOLUTION

• Variable declarations
• Instances and dot notation
• Constants
• Database evolution
Language evolution

The main principles of the language didn’t change


- Scripts (“programs”) are still executed
- The classes [L], [V] still exist but global variables use is
almost forbidden
- Call and Func still exist

The keywords of the language have been cleaned up:


- 153 keywords deprecated
- 55 new keywords
- 267 public keywords
- 121 internal classified keywords
Version 7 technology – training 8
Language evolution
New variable declarations
Data types have been added
- Date / Time
- Unique IDs
- Pointer on a class Instance

Libelle has been renamed to TinyInt

Additional functions added to handle these new types


- Time stamps
- Conversion functions
- Null pointers values

Technical database properties use these types

Arrays can now have variable dimensions

Version 7 technology – training 9


Language evolution
UUID
Universally Unique Identifier
- A standard published by the Open Software Foundation (OSF).
- Unique identifiers without conflicts in distributed systems
- Canonical format: hex digits with hyphen separators (8-4-4-4-12)
- Stored on 16 bytes (Approximately 3*10^38 different values)

Language keyword
- Declaration Uuident
- Functions Nulluuid Null value for UUID
Touuid (string) Canonical to UUID transformation
num$(uuid) UUID to canonical transformation
Getuuid Returns a valid UUID

Version 7 technology – training 10


Language evolution
UUID
Use in database
- By default, a standard technical column is added (AUUID) on all
tables
- Not filled during migration on existing tables

Used by CRUD management


- Assigned by the supervisor in CRUD management if not filled
- Identifies a record even if complex updates are done in nested grids

What can it be used for?


- We don’t use it in X3 tables as unique key
- Useful for synchronization issues (Sdata for example)

Version 7 technology – training 11


Language evolution
Datetime
Combined date and time value
- Combined format stored independently from time zone
- Canonical string format: YYYY-MM-DDThh:mm:ssZ
(T is a constant, Z for UTC)
- Example : 2013-12-25T13:03:05Z

Language keyword
- Declaration Datetime
- Functions gdatetime$(string) Canonical to datetime transformation
num$(datetime) Datetime to canonical transformation
datetime$ Returns the current datetime

Version 7 technology – training 12


Language evolution
Datetime
Use in database
- UPDDATTIM and CREDATTIM replace by default the previous
CREDAT, UPDDAT, CRETIM, UPDTIM columns
- Assigned by the supervisor in CRUD operations

Linked functions
- timestamp$ returns a timestamp (independently from time zone)
(string containing the number of milliseconds elapsed since 1970,1,1)
- time$ returns a string containing the current hour in server local time
("hh:mm:ss" format)
- date$ returns a date value containing the current date in server local
time

Version 7 technology – training 13


Language evolution
Variable Length Arrays
Arrays can be declared without maximum dimension
- Syntax examples:
Local Integer UNLIMITED(1..)
Local Char NO_BOUNDARY(100)()
Local Decimal MATRIX(1..,1..)

The previous declaration syntaxes are still usable

Maximum dimension
- The arrays are still limited to 32,767 rows
- dim is no longer relevant (it returns always 32767)
- maxtab gives the maximum index number that has been assigned (works
also with fixed size arrays)

Version 7 technology – training 14


Language evolution
Variable Length Arrays
Access to array elements
- Still done with UNLIMITED(I)=value
- This creates a cell if it didn’t exist before
- If a cell has not been assigned, UNLIMITED(I) will return a null value:
- 0 if numeric
- empty string value string$(0)
- [0/0/0] if date
- Nulluuid for an UUID
- Null for an instance pointer
- Unlimited arrays are recommended when potentially big variable lines
arrays have to be managed (if fixed or less than 10, use fixed numbers).
- Usable for collections and thus make the fixed sizing of documents
obsolete

Version 7 technology – training 15


Language evolution
Variable Length Arrays
A and B scripts can both call C or D script and will get the same result
But if A calls C, 32,767 loops will be performed !

A B
Local Integer MY_ARRAY(1..) Local Integer MY_ARRAY(1..10)
For I=1 to 10 For I=1 to 10
MY_ARRAY(I)=I MY_ARRAY(I)=I
Next I Next I
Gosub SQUARE_SUM Gosub SQUARE_SUM

C D
$SQUARE_SUM $SQUARE_SUM
J=0 J=0
For I=1 to dim(MY_ARRAY) For I=1 to maxtab(MY_ARRAY)
J+=MY_ARRAY(I)^2 J+=MY_ARRAY(I)^2
Next I Next I
Return Return
Version 7 technology – training 16
Language evolution
Class instances declaration
Classes are defined in dictionaries
- They can be seen as data structures with code that defines behavior
of the class and its properties
- An instance of a class is identified by a pointer variable declared by:
Local Instance NAME Using CLASS_IDENTIFIER
- A class identifier can represent a class or a representation
- If the instance is not created, the value of an instance pointer is Null
- Instance arrays can be declared and present in instances as
collections
- On an instantiated class, the dot notation is used to access to the
properties, for example:
MY_INST.PROPERTY = [L]MYVAL*3
TOTAL += MY_INST.LINE(3).SUB_LINE(2).NUMPROP

Version 7 technology – training 17


Language evolution
Methods
Classes can have methods or operations
- They can be seen as functions / behaviors used on instances
- Calling a method will be done by:
RET_VAL= Fmet INST_NAME.METHOD_NAME(PAR_LIST)

- In the code of the method, This identifies the current instance

- Rules can be defined for properties in a class. They are triggered by


the X3 engine or the supervisor to control access to the properties.

- The rules also use This to identify the current instance


- Example:
# This code is called to give a default value to CUR
This.CUR="EUR"
Version 7 technology – training 18
Programming style
Constants : have a more readable code
Not an evolution of the language but a preconisation
To avoid to use numeric values
for status, for example fstat):
–A constant dictionary exists
–It generates and assigns
global variables that are
supposed to remain constant:
[V]CST_xxxxxx
–The supervisor constant code
starts with A,
–Developers can add other
constants in the dictionary

Version 7 technology – training 19


Programming style
Constants : have a more readable code
Main constants used
Use case Values Use case Values
Return status [V]CST_AOK, Return status [V]CST_AOK,
for database [V]CST_ALOCK from methods [V]CST_ASUCCESS
operations [V]CST_AOUTSEARCH and operations [V]CST_AINFO
[V]CST_ADUPKEY [V]CST_AWARNING
(fstat values)
[V]CST_AOUTKEYS [V]CST_AERROR
[V]CST_ANOREC [V]CST_AFATAL
[V]CST_RECTICKDEL Line status for [V]CST_ALL
[V]CST_RECTICKUPD [V]CST_ANEW
collections in
Parameter [V]CST_ALEVFLD CRUD line [V]CST_ADEL
definition [V]CST_ALEVCPY [V]CST_AUPD
management
level [V]CST_ALEVFCY [V]CST_ANEWDEL
[V]CST_ALEVLEG Line position [V]CST_AFIRSTPOS
[V]CST_ALEVUSR [V]CST_ALASTPOS
for collections
Boolean [V]CST_AFALSE [V]CST_ANOTDEFINED
[V]CST_ATRUE
Version 7 technology – training 20
Language evolution
Database evolution
The way the supervisor handles updates on entities
changed between version 6 and version 7:
– In version 6, we use pessimistic lock:
–The first user displaying a record locks it even if his intention
was not to modify it.
– Consequences : a lock can be long, database contention on
“symbolic locks”
–In version 7, displaying a record does not lock anything:
–At user update, the conflict is detected with a “revision
number”
–Consequence: no database contention, the first modifier
wins
Version 7 technology – training 21
Database evolution
Version 6 pessimistic lock
The user wants to display the
record for BCUSTOMER
MARTIN in object BPC
BPCUSTOMER table APLLCK table
Record MARTIN is read Record BPC/MARTIN
The record is
creation attempt
displayed

Lock pad displayed Lock


Modification impossible successful
YES
Modification allowed

BPCUSTOMER table APLLCK table


User triggers update Record BPC/MARTIN
Record MARTIN updated
deleted

Version 7 technology – training 22


Database evolution
Version 7 optimistic lock
The user wants to display the
record for MARTIN instance of
BPCUSTOMER class
BPCUSTOMER table
Record MARTIN is read Class instance MARTIN displayed
Revision number is N revision number N

The user decides to modify the


BPCUSTOMER table record
Record MARTIN updated
only if Revision is still N
The user triggers the update

Update YES
Modification successful
successful
Revision number is now N+1

Modification failed
Version 7 technology – training 23
Language evolution
Database evolution
Version 7+ revision number
– When the data is read, a technical property named updTick
stores the “revision number’” of the record (1 just after creation,
incremented by 1 through a database trigger every time a
modification is done).
– 2 new instructions have been added to control updTick values:
– RewriteByKey key=key_value updates the record only if the
updTick was not changed
– DeleteByKey key=key_value deletes the record only if the
updTick was not changed
- 2 new fstat values to detect when updTick changed:
[V]CST_RECTICKDEL
[V]CST_RECTICKUPD
Version 7 technology – training 24
Language evolution
Database evolution
Summary: columns added in database description
Column name Data type Definition Comments
This columns stores the creation date & time. It is
Replaces CREDAT and CRETIM (used in v6, still available, but
CREDATTIM ADATIM (Datetime) automatically filled by the supervisor when an insert
deprecated).
method is used on a class.

This columns stores the update date & time. It is


Replaces UPDDAT and UPDTIM (used in v6, still available, but
UPDDATTIM ADATIM (Datetime) automatically filled by the supervisor when an update
deprecated).
method is used on a class.

When a table is migrated to v7.0 from v6, this column is inserted,


but the existing lines will not have an Uuid assignment. Although an
This columns stores an unique identifier assigned by Uuid is a good candidate to be a unique key, this column has not
AUUID AUUID (Uuid)
the supervisor layer when an insertion is done. been done to be used as a key for external references. It is notably
used to identify children instances when CRUD operation are done
on nested classes instances.
When CRUD operation based on the supervisor layers are
performed, two instructions called DeleteByKey and
RewriteByKey provided by the engine are used in delete and
This column is a revision number for the line
UPDTICK update operations. They check that the Updtick value has not
changed between the read operation and the update or delete
operation.

Columns still used : CREUSR, UPDUSR, EXPNUM, ENAFLG


Columns deprecated : CRETIM, UPDTIM, CREDAT, UPDDAT

Version 7 technology – training 25


Language evolution
Database evolution
Local File behaviour
– In version 6, Local File is a costly instruction:
– clalev is used to avoid to open a table if already opened
– Consequences: side effect that might happen if:
– A filter or a where was set on the table
– An order by changed the default index
– In version 7:
– Local File has been optimized
– A LogicClose has been introduced and is used by the
supervisor transparently
Consequence: in code associated to classes, always open
the table you need, and don’t care about closing them
Version 7 technology – training 26
Language evolution
Evalue SData
This function defines a filtering condition on a database query.
– The condition is expressed in SData where syntax.
– This function is only valid inside a Where clause of a database
instruction.
In some ERP pages, SData syntax conditions can be added
(requester conditions, filtering paging conditions in query list)
– The supervisor take care of these expression by using this function
– Syntax:
– Where evalueSData(EXPRESSION, VARIABLES, COLUMNS)
– EXPRESSION is a filter expressed in SData where syntax.
– VARIABLES is an array containing the variable names used in the
filter.
– COLUMNS is an array containing the database columns referenced
by the variable names.

Version 7 technology – training 27


Language evolution
Sdata example
Local File MYTABLE [MYT]
Local Char VARS(20)(1..3), COLS(20)(1..3)

VARS(1)="country" : VARS(2)="city" : VARS(3)="total"


COLS(1)="[MYT]COUNTRYCODE" : COLS(2)="[MYT]CITYNAME"
COLS(3)="[MYT]AMOUNT"

# The condition
Filter [MYT] Where evalueSData(
& "(city in 'London','Paris') and (total between 1 and 10) and country ne 'BE'"
& , VARS, COLS)

# is equivalent to
Filter [MYT] Where find(CITYNAME,'London','Paris')<>0
& and (AMOUNT>=1 and AMOUNT<=100) and COUNTRYCODE<>"BE"
Version 7 technology – training 28
CLASS MANAGEMENT

• Declaration
• Main characteristics
Classes management

A Sage ERP X3 class is very similar to a class in an Object Oriented language.


– It describes a structure which is shared by many objects called the instances of
the class. It also describes behaviours that are shared by the instances.

An instance of a class represents a specific object


– It has properties that contain values
– It can include instance of children classes:
CUSTOMER.ADDRESS for instance
– It can also include multiple instances called collections:
SALESORDER.LINES(INDEX).ITEM for instance

To create and manage a class


– We have to fill the class dictionary
– We have to validate the class

Version 7 technology – training 30


Classes management
The class dictionary
A new meta data dictionary
– With the same type of features (activity code protecting the entity or some
elements)
– With a description on 6 tabs

A class has to be validated before it can be used


– The validation performs consistency controls and generates code

Version 7 technology – training 31


Classes management
The class dictionary

The main characteristic of a class is its type that defines


– Its standard behavior
– The features and technical properties available

Different types of classes


– Persistent: the instance data is stored and retrieved from the ERP database
– Basic: the instance has no persistence methods, but can be embedded in
other instances
– Interface: a class with persistent methods that not necessarily refer to
database
– Technical / System: used by the supervisor when temporary structures are
needed

Version 7 technology – training 32


Classes management
The class dictionary

Characteristics of Persistent classes:


– The supervisor can provide AREAD, AUPDATE, AINSERT, ADELETE methods
to perform the persistence operations on persistent classes.
– Has to be linked to a unique main table:
– It can be the unique table managed by the class
– But it can also be linked to several tables with complex links (in this case,
children classes in collections are used): Sales Order class includes
children instances (1,N) of sales order line classes
Characteristics of Basic classes:
– No persistence methods available
– But can be embedded in a main persistence class that will carry persistence
operations.

Version 7 technology – training 33


Classes management
The class dictionary

Characteristics of Interface classes:


– The AREAD, AUPDATE, AINSERT, ADELETE methods can exist.
– No table associated to it (but a key can be declared)
– The developer has to write the code to implement the persistence method

This type of class is used with pages that looks like persistent classes on
entities that are not stored in the database.

Examples : X3 process management (list, detail read, deletion can be done)


Log file management

Version 7 technology – training 34


Classes management
The class dictionary

Other general characteristics of classes


–In cache describes a class dedicated to data stored in cache.
–Searchable means that an indexation can be performed to
search data in the class instances with the search box.
–Activity code and Module behaves as on the other
dictionaries.

Version 7 technology – training 35


Classes management
The class dictionary

Collections
A collection handles several occurrences of:
- A child instance of another class
- A list of fields
The properties of the collection are:
- Code: identifier used in the path to access collection properties
- Minimum number (0, 1, or Maximum).
- 0: an empty array is allowed
- 1: at least a line must exist
- Maximum: array with a fixed number of lines
- Activity code: if assigned must be of Sizing type
- Maximum no: not mandatory, can only be entered if no activity code
- Insertion, Deletion, Sort, Addition: actions that are possible on the collection. Refers
to standard collection methods
- Sequence counter: class property storing number of lines.
Version 7 technology – training 36
Classes management
The class dictionary

Scripts
Defines the list of scripts in which the event associated code is called
- The scripts are called in the order defined by the rank
- They can be defined as Standard, Vertical, Specific:
- Standard: only available for Sage, rank multiple of 1,000
- Vertical: used for vertical solutions
- Specific: used for code usually written for a unique customer
- Up to 20 scripts can be defined here
- The name of the script must follow one of the rules:
- CLASSx_CSTD, CLASSx_CSPE, CLASSx_CVER
Where CLASS is the class name, x an additional but optional character string
- Up to 20 scripts can be defined here
- The call of a script is disabled only if the activity code is set to Inactive.

Version 7 technology – training 37


Classes management
The class dictionary

Defines the list of global methods or operations for the class


- The associated code will be defined in the scripts
- Differences between methods and operations
- A method applies on a existing instance that is already on line. It is
stateful.
- An operation applies on a instance identified by a key. It is stateless.
The index used must be given
Both can have parameters and / or key values
- Only constants or properties that are “online” in the context
- If complex computation are required, they need to be stored in an
intermediate property
- Parameters can be class instances and/or arrays (index starting at 0 or 1)

Version 7 technology – training 38


Classes management
The class dictionary

Standard Methods
Only available for Persistent and Interface classes:
- A check box per CRUD operation to make them available
- The corresponding methods are
- AREAD (KEY_SEGMENTS)
- AINSERT
- AUPDATE
- ADELETE

Version 7 technology – training 39


Classes management
The class dictionary
A class can contain properties of any type:
- Single types such as date, alphanumeric, numeric, rich texts or plain texts
- Binary data such as images, rich texts, sounds, movies (a “mime type” is
supplied when UI is involved to allow the browser to use the right widget)
- Instances of children classes
- Examples: an invoicing address (class ADDRESS) included in CUSTOMER
definition, a set of INVOICELINE instances in INVOICE definition
- In this case, the data type is empty, and the class is filled
- References to other entities
– Example: a customer code in an invoice
– In this case, the data type is filled, but the type is associated to a class
- Arrays of properties from any other type
– Arrays (now called collections) are identified by a code
– A collection must also be created for a (1,1) child instance
Version 7 technology – training 40
Classes management
The class dictionary
Other characteristics of the properties in a class:
- Table of the lob and lob field when a clob/blob is stored in a dedicated table
- Content type for complex data types
- Mandatory flag (yes/no)
- Flag to enable the get accessor on properties. To avoid!
- Control tables and dependency (like in version 6)
- Access code to control the access to some critical Default
filter per
properties for users. indexed
- Searchable flag set if data must be indexed. entity

- Category is optional. Can be entered only if the property is


searchable. It defines additional search categories to refine Additional
the search. For example, If the zip code has a property filter by
values
associated to the COUNTRY category, a secondary filter found in
the
per country value will be displayed: country
category

Version 7 technology – training 41


Classes management
The class dictionary
Keys array
- Related to the current line in the property array
- Used for data types that refers to another entity
- Allows to define the key values to perform the link

Parameter array
- Related to the current line in the property array
- Used for data types that need parameters
- The parameter, their type, the transmission method are displayed
- Allows to define the parameter values

The same limits for the values in key and parameters as in methods/operations
- Only constants or properties that are “online” in the context
- If complex computation are required, they need to be stored in an intermediate
property
Version 7 technology – training 42
Classes management
The class dictionary

For persistent and interface classes only


- Defines how the supervisor handles the CRUD methods
- Header information
- Line information if collections of embedded classes exist
- A checkbox for every CRUD operation available
- If checked, the supervisor generates and calls the corresponding code
- Otherwise, the developer has to take care of the operation

For the header


- Read, Creation, Modification, Deletion check-boxes
- A filtering condition that can be used if it always applies for the entity

Version 7 technology – training 43


Classes management
The class dictionary
For the lines
- The join conditions are defined (for every variable collection in the class)
- Reference (class is displayed)
- Origin and destination table and abbreviation
- Link cardinality (0,1 or 0,N or 1,1 or 1,N)
- Sort index (if different from reference index)
- Join expression and filtering selection if any exist
- The key parameter are given in a dedicated array
- How the update is done on the lines
- A check box per CRUD method (as the header)
- If the referenced class is Persistent, the ability to call the
corresponding persistence method (otherwise the script updating the
line is embedded in the main class logic).
- A delete/insert checkbox: if checked, update on lines are done by
deletion + insertion.
Version 7 technology – training 44
Classes management
The class dictionary

Defines additional properties linked to security


- Legislation, Company, Site, Access Code
- Optional info that refers to properties present in the class
- Used to define the security filters on the records per user
- Also used to filter the search index results
- Filters
- Conditions defined by a code, a description, and a filtering condition
- Used to filter the data in different cases (especially user interface)
- Linked object
- Code of the object (used to allow a link from a read-only
representation to the classic page object)

Version 7 technology – training 45


Classes management
Global operations
Validation
- Performs all the controls and generates the corresponding scripts
- Necessary to use the class

Global validation
- Performs the validation for the class and all its embedded children classes
- The validation is done in the reverse order (the lower level classes
first)

Tree view
- Displays a hierarchical nested view of a class and its embedded children
- All the collections, scripts, tables.. Can be seen
- A summarized view with an indication of the depth is also given

Version 7 technology – training 46


Classes management
Tree view example

Version 7 technology – training 47


Writing code in classes

• Structure pattern
• Class instance
• Dot notation
• Events & properties
• Standard methods
• Collections
Classes management
Writing code in classes

A class catches the whole business logic of an entity


- Once defined, a class must be usable to manage consistent entities directly
in a program without user interaction
- This is used when performing unit tests and must be considered as the first
step (best practices)
- This means that in the script associated to a class, there is no reference to
user interaction

The user interface code can be written later


- The representation will refer to classes
- Additional properties dedicated to UI will follow (data required for easing the
data entry: : assistants related data, additional information…)
- Links will be defined to trigger class methods or operations, or additional UI
operation.

Version 7 technology – training 49


Classes management
Writing code in classes
What code is no more written for persistent classes?
- All the code related to the read, write, update, delete operations
- On header, lines, sub-lines, sub-sub-lines if necessary
- All the code that has already be associated to the data types
(references, additional controls, default values can be defined once).
- So dictionary descriptions can be enough the run a complex
entity!

What is the code we will have to add?


- Complex operations or methods that cannot be described in meta
data (shipping an order, computing the total amount of an invoice…)
- Controls or default values that are specific to a property in a class
instance
Version 7 technology – training 50
Classes management CRUD related operations
Writing code in classes EVENTS
INIT
In a transaction
Create a new(either
instancein interactive Readmode or in serviceREAD EVENTS
an instance
mode), we INITIALIZATION
DEFAULT have 3 main steps:
VALUES
- The Initialization that can be done by reading an existing record
ASSIGN
(we are still in stateless mode) or by assigning default values
or INPUT RULES
when startingAssign / compute
a creation Insert / Delete lines Call global METHODS
VALUES (CONTROL, values in the assign values on methods EXECUTION
- The assignment
PROPAGATE) or the inputchildren
class instance of values
instances(that triggers controls,
reassignments, initial values of lines are inserted). In UI mode,
COLLECTION EVENTS
the user has the hand. RULES (CONTROL,
DEFAULT VALUES PROPAGATE) ON LINES
- Update triggering (the user has no more the hand in UI)
(LINES)

- Let’s see it …
The 3 main steps in a transaction
TRIGGER
CONTROL BEFORE /
UPDATE (interactive or service mode) CONTROL AFTER UPDATES
- Initialization (read or default EVENTS
values assignment)
EVENTS TRIGGERED
- Assignment or input of values Trigger database insertion,
DURING THE
(interactive in UI) deletion or update DATABASEUPDATE
- Update triggering (the user has no
more the hand in UI)
Version 7 technology – training 51
Classes management
Writing code in classes
Principles of event executions
SCRIPT # 1
- Any event associated to a class calls the $METHODS
$OPERATION, METHOD, or EVENT labels in the …
Return
right order of the scripts
$PROPERTIES
- Any rule associated to a property calls the …
$PROPERTIES label in the right order of the scripts Return

STANDARD
SUPERVISOR CODE SCRIPT # 2
$METHODS
ASSOCIATED TO GLOBAL EVENT
HANDLING …
CLASS End
$PROPERTIES
RULE TRIGGERED PROPERTY RULE …
BY ENGINE OR BY Return
SUPERVISOR

Version 7 technology – training 52
Writing code in classes:
CRUD management events pitfalls
Take care of the local variables
- Setting a local variable in a control event and use it again in another
event (propagate for instance) won’t work
- You have to consider that the nesting of code is like this one:

Calling program Class code Event code (files declared


(CRUD supervisor) (c_class.stc) in class dictionary)
Fmet CONTROL ARULE="CONTROL" $PROPERTIES
Gosub PROPERTIES Case ARULE
….. End
When "CONTROL"
Local Integer I
ACTION="PROPAGATE" I=value
Fmet PROPAGATE
Gosub PROPERTIES #…
# continue here End When "PROPAGATE"
# I value is not known here
Endcase
Return
Always open the additional tables without using clalev test
- You cannot make assumptions on the fact that a table is online and how
Version 7 technology – training 53
Writing code in classes
The structure of a script : 4 labels
$METHODS, $OPERATIONS, $EVENTS : methods, operations, global events
- [L]CURPTH is the class concerned (events):
- If empty, the main class
- If not empty, the child class / collection identified by its path
(for instance "LINE.SUBLINE")
- [L]AMETHOD, [L]AOPERATION, [L]AEVENT define the corresponding method,
operation, event:
- Methods and operations are defined by a name in the class
- Events are standardized: "AINSERT_CONTROL_BEFORE", "AREAD_AFTER"...
- [L]ARET_VALUE is the value returned by the method (its type may vary)
$PROPERTIES : rules for properties
- [L]CURPRO is the property concerned:
- It can be a path for a property in a children class
(for instance "LINE.SUBLINE.QUANTITY")
- [L]ARULE is the rule : "INIT", "CONTROL", "PROPAGATE", "GET"

Version 7 technology – training 54


Writing code in classes
Script pattern - class global events
############### # METHODS ###############
$EVENTS : # Events related to class methods: CURPTH= instance, ACTION=method
Case [L]CURPTH
When ""
Case [L]ACTION
When "AINSERT_CONTROL_AFTER" : Gosub AINSERT_CONTROL_AFTER : # Standard CRUD
When "AUPDATE_CONTROL_AFTER" : Gosub AUPDATE_CONTROL_AFTER : # Standard CRUD
Endcase
Endcase

When “LINE”
Case [L]ACTION
When "ADELLINE_BEFORE" : Gosub LINDELB : # Collection method
When "AINSERT_CONTROL_AFTER" : Gosub LINSCTA : # Standard CRUD operation on line
When "AUPDATE_CONTROL_AFTER" : Gosub LUPCTA : # Standard CRUD operation on line
When "AINSERT_BEFORE" : Gosub LINSBEF : # Standard CRUD operation on line
Endcase
Endcase
Return

Version 7 technology – training 55


Writing code in classes
Script pattern - class global methods & operations
############### # METHODS ###############
$METHODS : # Methods declared in the class definition : AMETHOD=method
Case [L]AMETHOD
When "COMPUTATION" : Gosub COMPUTATION : # Method (called on the working copy)
Endcase
Return

############### # OPERATIONS ###############


$OPERATIONS : # Operations declared in the class definition : OPERATION=operation
Case [L]AOPERATION
When "VALID" : Gosub VALID : # Class operation
When "DUPLICATE" : Gosub DUPLICATION : # Class operation
Endcase
Return

Version 7 technology – training 56


Writing code in classes
Script pattern - class properties
############# # PROPERTIES #############
$PROPERTIES : : # Rules related to class methods: CURPRO= property, ACTION=method
Case [L]CURPRO
When "PROP1" : Gosub PROP1 : # Methods attached to property PROP1 in header
When "LINE.PROP2" : Gosub PROP2 : # Methods attached to property PROP2 in line
Endcase
Return
$PROP1
Case [L]ARULE
When "INIT" : Gosub INIT_PROP1 : # Init method attached to PROP1
When "CONTROL" : Gosub CONTROL_PROP1 : # Control method attached to PROP1
When "PROPAGATE" : Gosub PROPAGATE_PROP1 : # Propagate method attached to PROP
When "GET" : Gosub GET_PROP1 : # Get method attached to PROP1
Endcase
Return
#######
$PROP2
Case [L]ARULE
When "INIT" : Gosub INIT_PROP2 : # Init method attached to PROP2 in line
….
Version 7 technology – training 57
Writing code in classes
Standard properties
Standard properties present in every class
– this : reference to the current instance
– this.APARENT : reference to the parent instance
Take care when using it : don’t perform global control at lines level
- this.ACTX : context
Gives access to the parameters (replaces global variables):
Variable Contents
USER Connection user
AFOLDER Current folder
LAN Connection language

- this.snapshot : initial values


Gives access to initial values for properties in a class
- this.AERROR : array of error instances
Used to manage errors through dedicated methods
Version 7 technology – training 58
Writing code in classes
Snapshots

Provides ‘Copy’ of record before modifications


– Allows differences between modified and original record to be
determined
– Allows original record details to be restored if modification cancelled
– Useful when controls needs a comparison with the original value of a
property
– Automatically managed by the supervisor (created in AINIT and AREAD
events), but can be managed with dedicated instructions.

For any property in a class:


– MYINST.PROPERTY previous value is available in
MYINST.snapshot.PROPERTY

Version 7 technology – training 59


Writing code in classes
Snapshots

How does the snapshot work


– The snapshot structure is an empty structure at declaration time
– The engine returns the current property if no snapshot value exists
– At the first modification, the snapshot value is stored
Advanced functions and methods
MYINSTYANCE.snapshotEnabled
Internal property that is set to 1 if snapshot active (0 if not)
revertToSnapshot
Built-in method that reverts an instance to its snapshot state.
freeSnapshot
Built-in method that frees the snapshot (the current state will become
the new snapshot value)

Version 7 technology – training 60


Writing code in classes:
The context in event associated scripts

Case
$PROPERTIES When "CUSTOMER"
CURPRO this = the header
Rules triggered on this .CUSTOMER = the current value
this .snapshot.CUSTOMER = initial value
properties of the class

When "LINES.ITEM" this .LINES(INDEX).ITEM = a line property

Case
$EVENTS
CURPTH
When "" this = the current line
this .ITEM = the current value on the current line
Events associated to
the class or to a
this .snapshot.ITEM = initial value
children class this .APARENT.CUSTOMER = header value
When "LINES"

Version 7 technology – training 61


Writing code in classes:
Methods

A METHOD is a function attached to a class or a property that can be used to


manipulate the properties of a class instance.
Unlike an operation, that can be called without any preliminary context definition (a web
service, for instance), a method requires an instantiated class (we are in stateful mode).

A METHOD is declared in the class dictionary and called with the following instruction:

Fmet
– This operator invokes a method on an instance (similar to func).
– It is used to invoke methods that do return values.

Syntax: RETURN_VALUE= Fmet MYINSTANCE.METHOD


this
– Represents the current instance on which the method has been called

Version 7 technology – training 62


Writing code in classes:
Standard methods for persistent classes
At validation of a standard class, the supervisor generates scripts that implement
standard methods and operations (if selected):

– AREAD(KEY) : fills the instance from the database

– AINIT : fills the instance with default values (when creating a new data set)

– AINSERT : stores in the database a new instance

– ADELETE : deletes the current instance in the database

– AUPDATE : updates the current instance after modification

– ASETERROR(PROPERTY,MESSAGE,ERRORCODE) : records an error

– ADELETEERROR(PROPERTY) : deletes an error

– ASETATTRIBUTE(PROPERTY,ATTRIBUTE,VALUE) sets an attribute value

Version 7 technology – training 63


Writing code in classes:
Standard methods
Methods provided by X3 engine
- this.objecttype: code of the class associated to this
- this.objectnbs:: number of properties in the class associated to this
- this.objectvar(N): Nth property of the class associated to this

Version 7 technology – training 64


Writing code in classes:
Accessors
Properties have standard methods (Rules or Accessors)

INIT
– This method is called (through the class method AINIT) just after the creation of
an instance by the CRUD management generated code if a creation operation
is started (not if the instance will be fed by a read operation).
– It is also called on child class instances when a line is inserted.

GET
– This method is called when the value of property in a class instance is read.
– Called only if checkbox set for property
– Should be used only in exceptional cases (can be resource consuming)

Version 7 technology – training 65


Writing code in classes:
Accessors
Properties have standard methods (Rules or Accessors)

CONTROL
– This method is called when the value of a property in a class is updated. This
method can only verify that the value proposed is correct, optionally change the
value to be assigned, or refuse the assignment.
– It cannot assign other properties (this must be done in PROPAGATE method).
At control time, it is possible to have access to the original value through the
snapshot mechanism.
– This method is also directly called when you perform an update or an insert.

PROPAGATE
– This method is called after the CONTROL method when a modification has
been done (as soon as the modification was accepted and the field modified).

Version 7 technology – training 66


Writing code in classes:
Error Handling
Every class has an error instance array (AERROR)
A method ASETERROR allows to handle the errors
– In events code, Fmet this.ASETERROR(PRO,MES,STA) reports the errors.
– Can be called several times when more than one error has occurred.
– The method ADELETEERROR(PROPERTY) deletes the errors on a property
– The method AGETMAXERROR(PROPERTY) returns the most severe error code

Parameters of AERROR
- PRO is the property name (empty if a global error on the class)
- MES is the message sent (use only localized message)
- STA is the status: [V]CST_ASUCCESS OK, no message
[V]CST_AINFO Messages displayed but
[V]CST_WARNING operation is done

[V]CST_AERROR Error occurs and


[V]CST_AFATAL operation is not done
Version 7 technology – training 67
Writing code in classes:
Error Handling

The ASTATUS variable


– This variable is available on all the events, whenever this is available or
not.
– The value range is the same than the status values used by the
ASETERROR method.

Setting this variable to [V]CST_AERROR or [V]CST_AFATAL is


important when an error occurs, because these values are tested by
the supervisor layer on return from event code.

Version 7 technology – training 68


Writing code in classes:
Attributes Handling
Every class has an ASETATTRIBUTE method
This allows to handle attributes for a given property
The following syntax is used
– Fmet THIS.ASETATTRIBUTE(PRO,ATTRIBUTE,ATTVAL)

Parameters of ASETATTRIBUTE
- PRO is the property name
- ATTRIBUTE is the attribute name:
- "$isMandatory" is the only attribute available for classes (others exist for the
UI definition)  set to true means that the property must have a value.
- ATTVAL is the value that can be "false" or “true"

Version 7 technology – training 69


Writing code in classes:
Events in Detail ($EVENTS) - Events
For every event defined on the class or on a children class, a call is performed (label
$EVENT) with the following information:
– AEVENT is the code of the event
– CURPTH is the class path (not empty for children classes)
– this is the current class instance
– The code can perform the action attached to the event:
What can be done at this level:
– Update instance properties
– Trigger database modifications (in update events)
– Change instance property attributes
– Record error messages with error methods
Notes:
– To access a property of the current instance, this prefix is mandatory

Version 7 technology – training 70


Writing code in classes:
Methods in Detail ($METHODS)
For every custom method) defined on the class, a call is performed (label
$METHODS) with the following information:
– AMETHOD is the code of the method
– this is the current class instance (only for methods)
The code can perform the action attached to the event:
– ARET_VALUE is the value returned (type depends on the way it has been declared)
– The additional parameters (including key values for operations) are available
What can be done at this level:
– Update instance properties
– Change instance property attributes
– Record error messages with error methods
Notes:
– To access a property or a method of the current instance, this prefix is mandatory

Version 7 technology – training 71


Writing code in classes:
Operations in Detail ($OPERATION)

Works the same way than METHODS, but does operate in stateless way
– The key are sent as parameters, the instance is created but empty
– The variable is AOPERATION and not AMETHOD

On an operation, the code has to:


– read the data
– perform the operation (or the method on a class that has been instantiated)
– Free the resources allocated: the main resource will be freed automatically, a
good practice is to allocate them in the same group.

Version 7 technology – training 72


Writing code in classes:
CRUD events in detail
Called only if the CRUD method is not managed by supervisor
– If the check boxes are not set in the class dictionary (persistent classes)
– For interface classes (always)
A working copy is available:
– this refers to the current instance, CURPTH is the class path (empty if main class)
– ASETERROR method must be used to trigger an error (a rollback will be triggered)

Events Called Context


AINSERT Instance filled, all the controls have been done, insertion is requested (it can be
for a line during an update on a complex document), transaction in progress.
AINSERT_ROLLBACK Only if Rollback triggered by ASETERROR method in a previous event.

AREAD Read operation to fill a working copy.The key values are stored in local variables
that have the name of the key segments.
AUPDATE The instance is filled, all the control have been done, this.snapshot gives the
previous value, an update transaction is in progress.
AUPDATE_ROLLBACK Only if Rollback triggered by ASETERROR method in a previous event.

ADELETE The instance is filled, all the control have been done, a delete transaction is in
progress (can be on a line during a complex document update).
ADELETE_ROLLBACK Only if Rollback triggered by ASETERROR method in a previous event.
Version 7 technology – training 73
Writing code in classes:
properties events in detail
Called by the engine (GET, CONTROL, PROPAGATE) when access or
update of a property is done
– this refers to the current instance, this.PROPERTY accesses to the property
PROPERTY, CURPRO is the property name.
– ASETERROR method must be used to trigger an error (a rollback will be
triggered)
Events Context
Called
INIT Called for every property by the supervisor layer when a creation is requested (not for a modification).
Used to give default values.
Also done at the end of the initialization with CURPRO=“”
GET Called when a value of a property has to be used. If the value needs to be computed, the computation
will be done in the event and assigned to this.PROPERTY
CONTROL Called every time a property modification is executed. The initial value is available through this.snapshot.
No assignment can be done here, but an error can be thrown if the new value is not accepted.
PROPAGATE Called every time a property has been modified. Assignment of other properties can then be done.

Version 7 technology – training 74


Writing code in classes:
Control events in detail
Called if the CRUD method is managed by supervisor
– Allows to add controls before or after standard controls
– No database transaction started yet

Events Called Context

Before the insertion of a line in the instance, and before the


AINSERT_CONTROL_BEFORE controls on the fields (can be used to assign default values on
properties).
After all the controls have been done, before the database
AINSERT_CONTROL_AFTER
insert operation.
Before the deletion of a line and the automated consistency
ADELETE_CONTROL_BEFORE
control of the referential integrity based on dictionary definition.
After all the consistency controls have been done, before the
ADELETE_CONTROL_AFTER
database line deletion.
Before the controls of the properties and before the update of a
AUPDATE_CONTROL_BEFORE
line. Can be used to assign default values.
After the controls of the properties and before the update of a
AUPDATE_CONTROL_AFTER
line. Can be used to perform additional consistency controls
Version 7 technology – training 75
Writing code in classes:
Update events in detail
Called during the update transaction
– Allows to perform additional database updates
– Can be used for controls within the transaction
– Errors will be raised by ASETERROR method
– If error occurs, the supervisor will handle the rollback of transactions

Events Called Context


AINSERT_BEFORE After all the controls have been done, but before the database insertion

AINSERT_AFTER Once the database insertion has been successfully performed.


Before the deletion of a line, once the automated consistency control of the
ADELETE_BEFORE
referential integrity have been done.
ADELETE_AFTER After the successful deletion of a line.
Called before the updates, once all controls of the properties have been
AUPDATE_BEFORE
done.
AUPDATE_AFTER Called after the successful database line update.

Version 7 technology – training 76


Writing code in classes:
Error events in detail
Called only when errors happen during the transaction execution.
– A rollback is performed first if the transaction has been initiated by the CRUD
operation
– Then the control is given to the event to perform additional operations if
necessary
Events Called Context
AINSERT_ROLLBACK A database insertion failed

ADELETE_ROLLBACK A database deletion failed


AUPDATE_ROLLBACK A database update failed

Version 7 technology – training 77


Writing code in classes:
Read events in detail
Called during the read operation.
– Allows to perform additional read operations
– No transaction is done here, no update must be done, we are in stateless
mode

Events Called Context


AREAD_BEFORE Before the database is read
AREAD_AFTER After the database is read

Version 7 technology – training 78


Writing code in classes:
Collection management
A collection can be seen as an unlimited array of references to children instances

Technical properties are automatically added in collections:


– ASTALIN: line status when managing collections of children instances, with the
following values : [V]CST_ADEL, [V]CST_ANEW, [V]CST_AUPD,
[V]CST_ANEWDEL…)
– AORDER : logical rank used in the array (will be used for display operations in
representations)
Additional methods generated in the standard class are available for collections:
– ADDLINE(COLLECTION,POS) : adds a line in a collection in position POS
(POS=[V]CST_ALASTPOS  adds a line at the end). Returns the index, positions
AORDER with the right POS value.
– ADELLINE(COLLECTION,POS) : deletes a line in a collection in current POS.
– AGETINDBYLINE(COLLECTION,POS) : returns the index of the line instance
according to the position. The index starts from 1. This value is also returned by the
other methods.

Version 7 technology – training 79


Writing code in classes:
Collection management
Perform a loop on a collection must take in consideration 2 facts:
– maxtab must be used and not dim
– A collection is an unlimited array of instances starting at index 1. A collection
value can therefore have a null value, and the code should be written as
this example:
GRANDTOTAL=0
For I=1 to maxtab(this.LINES)
If this.LINES(I)<>Null
GRANDTOTAL+=this.LINES(I).TOTAL
Endif
Next I
A new syntax simplifies the aggregation operator use on member of
collections :
sum(COLLECTION(1..MAX).PROPERTY) sums on all the existing lines
avg, min, max, prd, uni work as well with this syntax.
Take care : at least a line must be present otherwise sum returns an error
Version 7 technology – training 80
Writing code in classes:
Collection handling events in detail
Called on the insertion and deletion methods available on collections.
– this refers to the current line in the AFTER events
– this refers to the parent instance in the BEFORE events (ALINE gives the
position where the insertion or deletion is requested)
– At the before event, raising an error with reject the action
– At the after event, additional actions can be executed

Events Called Context


ADDLINE_BEFORE An insertion is requested on a collection (it can be refused)

ADDLINE_AFTER The insertion has been done (this is the new line)
ADELLINE_BEFORE Delete line is requested on a collection (it can be refused)
ADELLINE_AFTER The deletion has been done

Version 7 technology – training 81


Writing code in classes:
Header and line events handling
When classes are nested in a complex structure, you can have scripts at
every level
The events will be called on the different nested levels (when applicable)
- Header:
– Called once for the instance, CURPTH is empty
– CURPRO: current header property (if rules executed).
- Lines:
– called for every line instance, CURPTH gives the path (LINE for instance)
– CURPRO: current line property (if rules executed).
How are the actions nested?
– The *_BEFORE events are called before the nested sub-levels and
supervisor layer
– The *_AFTER events are called after the nested sub-levels and supervisor
layer

Version 7 technology – training 82


Writing code in classes:
Header and line events nesting
EXECUTION CONDITIONS TARGET CLASS SCRIPT LEVEL CURPTH this value
Once DOCUMENT DOCUMENT "" DOC
For every LINE (I)
BEFORE event

LINE LINE "" DOC.LIN(I)


LINE DOCUMENT "LIN" DOC.LIN(I)
For every SUBLINE(J)
SUBLINE SUBLINE "" DOC.LIN(I).SUB(J)
SUBLINE LINE "SUB" DOC.LIN(I).SUB(J)
SUBLINE DOCUMENT "LIN.SUB" DOC.LIN(I).SUB(J)
event
SUBLINE SUBLINE "" DOC.LIN(I).SUB(J)
SUBLINE LINE "SUB" DOC.LIN(I).SUB(J)
AFTER event

SUBLINE DOCUMENT "LIN.SUB" DOC.LIN(I).SUB(J)


Next SUBLINE(J)
event
LINE LINE "" DOC.LIN(I)
LINE DOCUMENT "LIN" DOC.LIN(I)
Next LINE(I)
event
Once7 technology – training
Version DOCUMENT DOCUMENT "" DOC 83
Classes management CRUD related operations
Summarized view of events EVENTS
READ EVENTS:
Create a new instance Read an instance AREAD_BEFORE
AREAD_AFTER

INIT INITIALIZATION

METHODS
Assign / compute Insert / Delete lines Call methods
CONTROL EXECUTION
values in the class assign values on
PROPAGATE instance children instances OPERATIONS
Call operations
EXECUTION
COLLECTION EVENTS
INIT PROPAGATE
ADELLINE_BEFORE
ADELLINE_AFTER
ADDLINE_BEFORE CONTROL
ADDLINE_AFTER on properties in collections

CONTROL BEFORE / AFTER UPDATES EVENTS

CONTROL AINSERT_CONTROL_BEFORE AINSERT_CONTROL_AFTER


AUPDATE_CONTROL_BEFORE AUPDATE_CONTROL_AFTER
ADELETE_CONTROL_BEFORE ADELETE_CONTROL_AFTER
ROLLBACK EVENTS:
AINSERT_ROLLBACK BEFORE / AFTER UPDATES EVENTS:
AUPDATE_ROLLBACK Trigger database insertion,
deletion or update AINSERT_BEFORE AINSERT_AFTER
ADELETE_ROLLBACK
ADELETE_BEFORE ADELETE_AFTER
Version 7 technology – training AUPDATE_BEFORE AUPDATE_AFTER
84
DATA TYPE DICTIONARY
Data Type dictionary
Provides consistency of properties (type, length…)
In v7.0, the data types have been reorganized in 3 tabs:

Data types are used in the different dictionaries: table, classes,


representation.

The data type dictionary is not a new dictionary, but it has significant
evolutions.

Data types continue to support the behaviors needed by Classic page


technology, but they also support new version 7 features.

Version 7 technology – training 86


Data Type dictionary
Provides consistency of properties (type, length…)

Includes the following info:


- Activity code and module
- Unchanged since version 6

Internal type
- New types are available
- A data type cannot have the Instance type (this is only possible
through children classes declaration).

Version 7 technology – training 87


Data Type dictionary
Provides consistency of properties (type, length…)

Includes the information that were only needed in version 6:


- Linked object and table
- For Classic pages “tunnels” management
- Grid format, parameter and variable

- Grid format, parameter and variable


- Used for dynamic format management
- Not yet an equivalent function for the Version 7 client

Actions grid
- Still refers to the action dictionary that is no more used in V7

Version 7 technology – training 88


Data Type dictionary
Provides consistency of properties (type, length…)

Data type can have 3 values


- Simple: by default
- Reference: A data type that is a key to a given entity record
- Rich media: clob or blob with structures
Every data type has a content type (mime type for UI)

Simple data types


- Can have a special format
- Handled by the user interface (use of dedicated widgets)
- Email = link mailto: available in the UI
- Phone = link callto: available in the UI
- Password= dedicated input (masked) password
Version 7 technology – training 89
Data Type dictionary
Provides consistency of properties (type, length…)

Rules and parameters


- Allows to write code in dedicated library to perform default rules.
- The parameter value will be entered on the class definition.
- For the simple data type, the following rules are available:
Rule Purpose Minimum parameter expected
INIT Give a default value Variable Instance AINSTANCE Using OBJECT
Value Char APRONAME()
CONTROL Control the value Variable AVALUE : # Type depends on the Property
PROPAGATE Code executed after
successful update
GET Returns property value
FORMAT Done before control after Variable Instance AINSTANCE Using OBJECT
Value Char APRONAME()
assignment to verify Variable AVALUE : # Type depends on the Property
conformity with format Variable Char AFORMAT()
Version 7 technology – training 90
Example of code
Control for ADI data type

Funprog CONTADI_SYR(AINSTANCE,APRONAME, AVALUE, NUMTAB, DEPCOD)


Variable Instance AINSTANCE Using OBJECT
# other declarations…
If val(NUMTAB)<>0
Local File ATABTAB [ADV] : Local File ATABDIV [ADI]
Read [ADV]CODE = val([L]NUMTAB)
If !fstat
Read [ADI]CODE=val([L]NUMTAB);AVALUE
If !fstat
If [L]DEPCOD<>"" & [ADV]DEPNUM<>0 & [ADI]DEPCOD<>"“ & [ADI]DEPCOD<>[L]DEPCOD
ASTATUS = FMET AINSTANCE.ASETERROR(APRONAME,"Dependency error",CST_AERROR)
Elsif val(NUMTAB)=909
If !find(AVALUE, AINSTANCE.ACTX.AFOLD.ALISTLEG(1..AINSTANCE.ACTX.AFOLD.ANBLEG))
& & AVALUE<>""
ASTATUS = FMET AINSTANCE.ASETERROR(APRONAME,"Legislation unavailable",CST_AERROR)

EndifVersion 7 technology – training 91
End ASTATUS
Data Type dictionary
Provides consistency of properties (type, length…)

Reference data types


- Defines a key field on another entity. Additional fields have to be
entered:
- Class (mandatory)
- Default Representations for every device: not mandatory, will be
used for default navigation links (the equivalent of V6 “tunnels”)

Rule and parameters


- The same types of rules can be defined than for simple types
- For a reference key, a line is automatically inserted at the first
position (ACTLREF) that controls the referential integrity. The
corresponding code is generated. Additional controls can be added.

Version 7 technology – training 92


Data Type dictionary
Provides consistency of properties (type, length…)

Rich media data types


- Defines a clob or blob value.
- Additional types of rules can be set to allow to performs the updates
if the data is stored in a dedicated table or file, and also to define
dynamically the content type
Rule Purpose Minimum parameter expected
AREAD_MEDIA Data read Variable Instance AINSTANCE Using OBJECT
Value Char APRONAME()
Variable AVALUE : # Type depends on the Property
UPDATE_MEDIA Data update Variable Instance AINSTANCE Using OBJECT
Value Char APRONAME()
INSERT_MEDIA Data insert
DELETE_MEDIA Data delete
READ_MEDIA_CNT Returns media type Variable Instance AINSTANCE Using OBJECT
Value Char APRONAME()
Version 7 technology – training
Variable Char AVALCNT : # Content type 93
Data Type dictionary
Content type

An additional dictionary table


- That associates to a content type defined on every data type:
- An internal type (image or text)
- A default mime type

Predefined supervisor content type exist for all the other data types
- They cannot be modified

Version 7 technology – training 94


CLASS AS A SERVICE
How to use a class
UI vs service mode
When a user interface exists for a class
- the CRUD operation are supported by the supervisor.
- The developer has only to take care of the events that completes the standard method
When a class must be used from a script in service mode:
- The developer has to declare and handle the class
- A typical example of code would be:
Local Instance MY_ORD Using C_ORDER # Class pointer declaration

MY_ORD = Newinstance C_ORDER… # Class instantiation

OK = Fmet MY_ORDER.AINIT # Call of a method

MY_ORD.CUSTOMER = "MARTIN" # Property assignment

NUMLI=Fmet MY_ORD.ADDLINE("LINES", [V]CST_ALASTPOS) # Line insertion

MY_ORD.LINES( NUMLI) .ITEM="CD100" # Property assignment

OK=Fmet MY_ORD.AINSERT # Call of creation method

Version 7 technology – training OK=Freegroup MY_ORD # Release the instance 96


How to use a class
Instantiation of a class
The class has been declared in the class dictionary and validated
- We can declare an instance pointer on it
# Declare a “pointer” on an instance
Local Instance MYINSTANCE Using C_CLASS
- At this point, the value of MYINSTANCE is Null

The allocation will create the instance (allocates memory for it)
- This is done using NewInstance instruction.
- At the end, the developer will have to free the memory in a consistent way
(otherwise we will have memory leaks)
- The allocation is done in groups, and 2 syntaxes exist:
# Allocate in a new group
MYINSTANCE = NewInstance C_CLASS allocGroup Null
# Allocate in the same group than another instance
MYOTHERINSTANCE = NewInstance C_CLASS allocGroup MYINSTANCE
Version 7 technology – training 97
How to use a class
Free an instance
Free an instance can be done in two ways
- Free only one instance
FreeInstance MYINSTANCE
- At this point, the value of MYINSTANCE is not Null but accessing to
MYINSTANCE.PROPERTY will throw an error.

- Free all the instances that are in the same group than my instance
FreeGroup MYINSTANCE
- This syntax should be preferred, because the collections (children instances)
are instantiated in the same group than the main instance.

A function called Heapdmp dumps the instances created in a logfile


located in the TRA directory. The filename is returned by this function.
This is useful to diagnose the memory leaks.

Version 7 technology – training 98


How to use a class
Free an instance
Free an instance can be done in two ways
- Free only one instance
FreeInstance MYINSTANCE
- At this point, the value of MYINSTANCE is not Null but accessing to
MYINSTANCE.PROPERTY will throw an error.

- Free all the instances that are in the same group than my instance
FreeGroup MYINSTANCE
- This syntax should be preferred, because the collections (children instances)
are instantiated in the same group than the main instance.

A function called Heapdmp dumps the instances created in a logfile


located in the TRA directory. The filename is returned by this function.
This is useful to diagnose the memory leaks.

Version 7 technology – training 99


How to use a class
Call a method or an operation
Standard and specific methods are called by
RETURN_VALUE = Fmet MYINSTANCE.MYMETHOD

The CRUD methods can directly be used, with the following patterns:
- Create a new instance for a persistent entity
OK = Fmet MYINSTANCE.AINIT : # Fills default value, sets snapshot
If OK>=[V]CST_AERROR:…: Endif : # Handle errors
MYINSTANCE.PROP1= … : : # Assign properties
# Check the errors after the assignments
If MYISTANCE.AGETMAXERROR("")>=[V]CST_AERROR

Endif
OK = Fmet MYINSTANCE.AINSERT : # Create the records
If OK>=[V]CST_AERROR:…: Endif : # Handle errors

Version 7 technology – training 100


How to use a class
Call a method
The CRUD methods can directly be used, with the following patterns:
- Update an existing instance for a persistent entity
OK = Fmet MYINSTANCE.AREAD(KEY) : # Fills the records, sets snapshot
If OK>=[V]CST_AERROR:…: Endif : # Handle errors
MYINSTANCE.PROP1= … : : # Assign properties
# Check the errors after the assignments
If MYISTANCE.AGETMAXERROR("")>=[V]CST_AERROR

Endif
OK = Fmet MYINSTANCE.AUPDATE : # Create the records
If OK>=[V]CST_AERROR:…: Endif : # Handle errors

Version 7 technology – training 101


How to use a class
Call a method
The CRUD methods can directly be used, with the following patterns:
- Delete an existing instance for a persistent entity
OK = Fmet MYINSTANCE.AREAD(KEY) : # Reads the records
If OK>=[V]CST_AERROR:…: Endif : # Handle errors
OK = Fmet MYINSTANCE.ADELETE : # Deletes the records
If OK>=[V]CST_AERROR:…: Endif : # Handle errors

Version 7 technology – training 102


How to use a class
Call a method
Add or delete line in a creation / update pattern

# Add a line at the end (collection LINE)


LIN = Fmet MYINSTANCE.ADDLINE("LINE", [V]CST_ALASTPOS)
If LIN<>[V]CST_ANOTDEFINED : # If the addition is allowed
MYINSTANCE.LINE(LIN).PROP1= … : # Assign line properties
Endif

# Add a line at position 2 (collection LINE)


LIN = Fmet MYINSTANCE.ADDLINE("LINE", 2)
If LIN<>[V]CST_ANOTDEFINED : # If the addition is allowed
MYINSTANCE.LINE(LIN).PROP1= … : # Assign line properties
Endif

# Delete the first line (collection LINE)


LIN = Fmet MYINSTANCE.ADDELLINE("LINE", 1)

Version 7 technology – training 103


How to use a class
Standard methods vs additional methods

A standard method always returns a status


[V]CST_AOK, [V_CST]AINFO, [V_CST]AWARNING…
This status is returned in the standard event code by
[L]ASTATUS= [V]CST_AOK
or
[L]ASTATUS= fmet this.ASETERROR(…)

An additional method returns a value that depends on the method definition


This value is returned in the associated event code by
[L]ARET_VALUE = …

Version 7 technology – training 104


How to use a class
Transaction management
The transactions are still managed with
Trbegin TABLE1,TABLE2…
# Database operations
If ErrorConditions : Rollback : Else Commit : Endif

- A unique transaction can be done at a time


- The transaction must be committed or rolled back at the same level of calls
nesting
- Checking if a transaction is already opened is done by checking adxlog

How are the transaction managed in CRUD operations?


- An AINSERT or AUPDATE method opens a transaction if no transaction is
already opened, and commits or rolls back automatically if errors are set.
- If a transaction is already in progress, the methods only returns the status and
let the calling code handle the transaction.
Version 7 technology – training 105
TESTING TOOL

• Main principles
• Available functions
• Running the test
• Example
Automatic Testing Tools

Automated unit test was not easy to do in version 6:


- The code is difficult to insulate (global variables makes it difficult)
- The UI and the business rules are intertwined

In version 7 and further, we have a lot of code to rewrite or at least to


rework:
- This code is already defined as service
- Testing it will be much simpler

AXUNIT is dedicated to it:


- Definition of done must include non regression tests
- Should even be conducted before the UI design

Note: for the platform, a dedicated tool also exist (qunit)

Version 7 technology – training 107


Automatic Testing Tools
Main principles
A dedicated toolset has been implemented
– Based on a batch task (AXUNIT) that calls an XXUNIT script file
– The AXUNIT script file contains all the libraries
– Script test files name must follow the QLF*_* pattern

Script script files structure:


– The main function is a Funprog called TESTSUITE
– Adding a subtest in the scenario is done with ADD_TESTCASE
– Every sub-test is defined in a separated subprog and include calls to testing routines

Funprog TESTSUITE()
Call ADD_TESTCASE(LABEL1, COMMENT1, NBTST1) From AXUNIT
Call ADD_TESTCASE(LABEL2, COMMENT2, NBTST2) From AXUNIT

End
Subprog LABEL1
Call CHECK_EQUAL(V1,V2) From AXUNIT
Call CHECK_NOTEQUAL(V1,V2) From AXUNIT

End
Version 7 technology – training 108
Automatic Testing Tools
Available functions for result logging
All the functions mentioned here are in AXUNIT
– They are called with Call
– The result is stored in the log file generated
– The number of check calls must be mentioned in the ADD_TESTCASE
Function Purpose Parameter
CHECK_EQUAL(GOT, EXPECT) Check if GOT is equal to EXPECT GOT and EXPECT must have a
comparable data type:
- Numeric (any type)
CHECK_NOTEQUAL(GOT, EXPECT) Check if GOT is not equal to EXPECT - Date
- string or clob
- UUID
- Datetime
CHECK_TRUE(GOT) Check if GOT is true GOT can be any comparison
(logical value) or any numeric
CHECK_FALSE(GOT) Checks if GOT is false value (true means not equal to 0,
false means equal to 0)
LOG_LINE(MESSAGE) Writes a line on the log file MESSAGE is written on the log file
(does not count as a check call)
Version 7 technology – training 109
Automatic Testing Tools
Running the tests

Direct call from Eclipse Console:


=>func QLFRTM_XXX.TESTSUITE

QLFRTM_XXX - REQ-70693 - 4 Succeed, 0 Failed, 66ms elapsed


Trace has been written to ‘…/FOLDER/TRA/QLFRTM_XXX_usercode.tra‘
JSON result is available at:
http://myserv.../TMP/QLFRTM_XXX_usercode.json

Advantage: in Eclipse, the link opens the result file in an suitable editor

Even before designing the interface (representation will be done later), this
methodology allows to check in depth control quickly.

Version 7 technology – training 110


Automatic Testing Tools
Running the tests
Running all tests
Can be done by
func AXUNIT.RUN_ALL
Can take a long time, don’t run it directly from Eclipse
Can also be automated with the AXUNIT batch task

Running all tests except some of them


Can be done by
func AXUNIT.RUN_ALL2(EXCLUDES,NODEBUG)
EXCLUDES : string of program names separated by ;
NODEBUG : A value indicating if the debug mode must be disabled.

Running a subset of tests


Can be done by
func AXUNIT.RUN_SET(SET)
SET : string representing the set (QLFSET_*.src scripts will run)

Version 7 technology – training 111


Automatic Testing Tools
Additional features
Performing some initial tasks
Can be done by
Subprog SETUP
If it exists, it runs before the test suite

Performing some clean up tasks


Can be done by
Subprog TEARDOWN
If it exists, it runs after the test suite

A main principle:
- Tests must be repeatable
- Cleaning the database of what has been created can be done before or after the
running test

Version 7 technology – training 112


Automatic Testing Tools
What should be tested?
On a class that is persistent, we should at least test:
- The CRUD operations
- The dedicated methods and operations
- Requests with errors so we can verify that the controls are ok
- Requests that are on the boundary of what is allowed (verify what happens when
all the default values apply)

Version 7 technology – training 113


Automatic Testing Tools
Example (1)

This code has been written to test CRUD code on a complex (3 levels) entity:

Properties: YBPC, YREP, YORDDAT, YTOTAL…


YORDERH [YOH]
Properties: YITM, YPRICE…
YORDERLINE [YOD]
1,N
YORDERSUBLIN [YOL]
1,N
# Create an order
Properties: YUNIT, YQTY, YUNITPRICE
Subprog YORDER_AINSERT
Local Instance MYORDER Using C_YORDER
Local Integer I,J,K,L,OK
Local Decimal TOTAL_PRICE

MYORDER=NewInstance C_YORDER allocGroup Null

Version 7 technology – training 114


Automatic Testing Tools
Example (2)
# Double loop on lines and sub-lines with price computed on the fly
TOTAL_PRICE=0
For I=1 To 5 : # 5 lines inserted
J=fmet MYORDER.ADDLINE("YOD",[V]CST_ALASTPOS)
Call CHECK_TRUE(J>=0) From AXUNIT
# We use existing items coded "BMSMN0020x" where x varies from 3 to 8
MYORDER.YOD(J).YITM="BMSMN0020"+num$(2+I)
For L=1 To 4 : # 4 sub-lines inserted for every line
K=fmet MYORDER.YOD(J).ADDLINE("YOL",[V]CST_ALASTPOS)
Call CHECK_TRUE(K>=0) From AXUNIT
# We use successively the units "UN","TEN","CAR","PAC"
MYORDER.YOD(J).YOL(K).YUNIT=vireblc(mid$("UN TENCARPAC",3*L-2,3),2)
MYORDER.YOD(J).YOL(K).YQTY=I*L
MORDER.YOD(J).YOL(K).YUNITPRICE=5+L
TOTAL_PRICE+=(I*L)*(5+L)
Next L
Next I
Version 7 technology – training 115
Automatic Testing Tools
Example (3)
# A lot of mandatory properties have no value : LOG_ERRORS will dump them
OK=fmet MYORDER.AINSERT
Call LOG_LINE("Result of AINSERT") From AXUNIT
Call CHECK_EQUAL(OK,[V]CST_AERROR) From AXUNIT
Call LOG_ERRORS(MYORDER)
# Assigning the order number here will propagate
MYORDER.YORDNUM="314159"
# Check the propagation
Call LOG_LINE("Propagate checks") From AXUNIT
For I=1 To 5
For J=1 To 4
Call CHECK_EQUAL(MYORDER.YOD(I).YOL(J).YORDNUM,MYORDER.YORDNUM)
& & From AXUNIT
Next J
Call CHECK_EQUAL(MYORDER.YOD(I).YORDNUM,MYORDER.YORDNUM) From AXUNIT
Next I

Version 7 technology – training 116


Automatic Testing Tools
Example (4)
# Still a lot of mandatory properties have no value
OK=fmet MYORDER.AINSERT
Call CHECK_EQUAL(OK,[V]CST_AERROR) From AXUNIT
Call LOG_ERRORS(MYORDER)
# Now let's assign the missing mandatory values
# Customer code, sales rep code and currency code are supposed to exist
MYORDER.YBPC="BPC-000003"
MYORDER.YREP="REPRE004"
MYORDER.YORDDAT=[09/05/2002]
MYORDER.YCUR='EUR'
MYORDER.YSTATUS=1
OK=fmet MYORDER.AINSERT
# Check if the creation is OK
Call CHECK_EQUAL(OK,[V]CST_AOK) From AXUNIT
Call CHECK_EQUAL(MYORDER.YTOTAL,TOTAL_PRICE) From AXUNIT
FreeInstance [MYO]
End
Version 7 technology – training 117
ADDITIONAL FEATURES
- CONTEXT MANAGEMENT
- PRINCIPLES
- MAIN INTERESTING PROPERTIES
- HOW TO ADD GROUPS & PROPERTIES
- PARAMETER HANDLING
- CACHE MANAGEMENT
- AVOID class
- LOG FILES MANAGEMENT
Version 7 technology – training 118
ADDITIONAL FEATURES

• Context management
• Parameters handling
• Cache management
• AVOID class
• Log file management
• Asynchronous task (API)
Context code

In v6, creating software components remains difficult:


– No separation between business logic and UI – Class solve this in v7.0
– Global variables are used and creates dependencies between code layers
– It is impossible to execute from a component code with other connections
conditions (folder, language, user)
In v6, several performance issues based on parameters exist:
– 90% of the connection time is spent by global variables filling
– Parameter access (global parameters, sites, companies, currencies…)
generates a lot of database access
In v7, the context management solves these issues
– Creates contextual accesses to:
– General parameters
– Parameter tables
– Previous global variables
– Download is done on demand (no initialization time)
Version 7 technology – training 120
Context code
Definition
Context codes are to replace the old global variables defined in the v6
dedicated function (GESAGB). In v7. the new function defining the context
codes is the context dictionary.

A context code is the description of a variable that will be present in the


context class.
– This class identifies the context execution of Syracuse and includes notably the
definition of the current folder, of the current user, and other useful information
including general parameter values.

The main difference between the global variables defined in v6 and the
context is that we can now have several contexts simultaneously:
– This can be useful for instance, if we need temporarily to have access to
another set of global variables and parameters when performing an operation
that involves several folders or several users

Version 7 technology – training 121


Context
The context class
On every instance, an ACTX instance pointer exists
– this.ACTX gives access to the current context instance.
– GACTX is the default context instance defined at connection time (depends on
folder, user, language)
– The context class includes a initialisation method called by
Fmet ACTX_INIT_LAN(AFOLDER, LAN, LOGIN)
– A re-initialization method exist also:
Fmet ACTX_RE_INIT
Supports several other services:
– Access to global variables such as this.ACTX.USER (replaces GUSER)
– Access to other parameters by group defined in context dictionary.
– An APARAM child instance that supports the methods used to get access to
parameter values (GESADP dictionary that remains unchanged).
– An ACACHE child instance provides a cache storage for small parameter tables
(defined as cache classes).

Version 7 technology – training 122


Context:
Context class dictionary
Defines variables in chapters (equivalent of global variables)
– Chapters are defined by miscellaneous table #96
– Direct access with this.ACTX.MYGROUP.MYVARIABLE syntax
– The variables are initialized directly or the first time their value is needed
(through an accessor), they are read-only
– Checking the load on demand checkbox is recommended in most cases,
because it decreases the time spent for the initialization of a context.

Example of use:
Initialize a LANCODE property with the default language (in the script
associated to a class)
$PROPERTIES
Case CURPRO
When "LANCODE"
this.LANCODE = this.ACTX.LAN
Endcase
Return

Version 7 technology – training 123


Context:
Parameters (General)
Methods of ACTX.APARAM to retrieve parameter value
– The rules for parameter definition hierarchy and access priority didn’t change
- When search a parameter value assigned at Folder, Legislation, Company, or
Site level (regardless of the level of definition), 3 methods are available :
AGETVALCHAR(TYPCOD,TYPVAL,PARAM) to get an alpha value
AGETVALNUM(TYPCOD,TYPVAL,PARAM) to get a numeric or local menu
AGETVALDEC(TYPCOD,TYPVAL,PARAM) to get a decimal
AGETVALDATE(TYPCOD,TYPVAL,PARAM) to get a date value
These 3 methods take the same parameters:
– TYPCOD is code of the assignment level of your search
([V]CST_ALEVFOLD : Folder, [V]CST_ALEVCPY : Company,
[V]CST_ALEVFCY : Site, [V]CST_ALEVLEG : Legislation)
– TYPVAL is the code of Folder/Legislation/Company/Site
– (depending on TYPCOD)
– PARAM is the parameter code
Version 7 technology – training 124
Context:
Parameters (User)

Methods of ACTX.APARAM to retrieve user parameter


value
– to find a parameter value assigned at user level (the level of definition
must be user), 3 methods are available:
AGETUSERVALCHAR(PARAM) is used to get an alpha value
AGETUSERVALNUM(PARAM) is used to get a numeric or local menu value
AGETUSERVALDATE(PARAM) is used to get a date value

These 3 methods take the same parameter:


– PARAM is the parameter code

Version 7 technology – training 125


Context:
Cache Classes
Used to avoid too frequent access to database for small tables containing
parameters or main data:
– Examples : company, sites, units
Declaration
– Must have the in cache check box set
– Needs a context re-validation after creation of such a class
Main restrictions:
– should only contain a restricted list of properties
– cannot contain a collection.
– can only be persistent or interface
– is read-only and doe not support accessors (control, propagate..)
– No other methods than AREAD, no other events managed than AREAD (if
interface), AREAD_BEFORE , AREAD_AFTER (if persistent).
– Not usable for the CRUD management on the corresponding table

Version 7 technology – training 126


Context:
Cache Classes
The supervisor predefines some cache classes (starting with A):
– ACPY, AFCY, ACUR, ALEG (companies, sites, currencies, legislations)

Declaration of cache classes


– Declare only a limited number of buffer classes for small tables” (they will be
stored and remain in the context)
– Class buffers should be named with the abbreviation of the table whereas the
associated CRUD class is named with the table name

Use of buffers:
– ACTX. ACACHE gives access to the different buffer instances
– For a XXX buffer class, ACACHE.XXX.ACOL is an array of instances storing
the buffered properties cached for the buffer class.
– ACTX.ACACHE.XXX provides access methods to the data buffered

Version 7 technology – training 127


Context:
Cache Classes
Access methods of ACTX.ACACHE.XXX:
– AGETINDEX(KEYS) : returns the index of the buffered instance for the
corresponding key values. If the value was not read, this method performs the
read. If no record exists for the given key value, this methods returns
[V]CST_ANOTDEFINED.
– AGETVALCHAR(KEYS,"PROPERTY_NAME") : returns a character type
property.
– AGETVALNUM(KEYS,"PROPERTY_NAME") : returns an integer typed property.
– AGETVALDEC(KEYS,"PROPERTY_NAME") : returns a decimal typed property.
– AGETVALDATE(KEYS,"PROPERTY_NAME") : returns a date typed property.

In the previous syntaxes, KEYS is a list of parameters corresponding to the


values of the different key segments.

Access to a PROPERTY with the index retrieved by AGETINDEX:


– ACTX.ACACHE.XXX.ACOL(index).PROPERTY
Version 7 technology – training 128
Additional tool:
AVOID instance
A dedicated AVOID instance (global variable) is provided
– It includes a property of every type
– It is used as a “black hole”: CHARACTERISTICS OF AVOID
– Assignment of their properties does nothing Property Data type
– They always return “null values” ACHAR Character string

Purpose of this feature: AINT Integer

- To allow explicitly a developer to ignore the ADEC Decimal number


return value of a method: ADATE Date
# My method does not return a relevant value ALIB Local menu (byte value)
AVOID.AINT=Fmet this.MYMETHOD ACLOB CLOB (large character file)
ABLOB BLOB (large binary file)
# Assign to MYDATE a null date AINS Instance pointer
this.MYDATE=AVOID.ADATE AUUIDENT Unique ID
ADATTIM Date time

Version 7 technology – training 129


Additional tools:
Log Files

From v7, a new set of functions are implemented in the supervisor.


They create and populate the log file in the same format as v6, but they are
more appropriate to use when working with classes and methods.

To create a log file you have to create an instance of the ALOG class. Once
this instance exists, different methods will allow the user to write log files.
They are all called by Fmet

They all return a numeric status ([V]CCST_AOK, [V]CST_AERROR…)


except AGETNAME.

Version 7 technology – training 130


Additional tools:
Log Files methods
ASETNAME(FILE_NAME)
Defines the log file name. If this method is not used, the name will be "F" followed
by an incremental number defined by [C]NUMIMP current pointer value.

AGETNAME
Returns the file name used for the log files, and assigns it by default (if not
defined)

ABEGINLOG(TITLE)
Starts the log creation process, sets up the title of the log file

APUTLINE(TEXT,STAT)
Creates lines in the log and writes them in the log file depending on buffering
conditions
Version 7 technology – training 131
Additional tools:
Log Files methods
AENDLOG
Ends the log creation process, writes log file on disk, and closes the file

AFLUSHLOG
Flushes the log file by writing the buffered log lines on disk

APUTERRS (ERRCLASSINSTANCE)
This method will directly write in the log file the detailed error messages found in
the error class associated to the class instance

APUTINSTERRS (CLASSINSTANCE)
This method will directly write in the log file the detailed error messages found in
the error class associated to the class instance and all its children instances

Version 7 technology – training 132


Additional tools:
Libraries for multi-folder parameter access
When accessing to parameter in another folder, the V6 supervisor libraries can
no more be used because of global variables. Some of them have already been
re-implemented:

Funprog ADP_TOOL.GET_PARAM(FOLDER, LEVEL, LEVVAL, PARAM)


Returns a parameter value in a string
LEVEL=[V]CST_ALEV* (FOLD,CPY,FCY,LEG), LEVVAL=the corresponding code

Funprog ADP_TOOL.GET_PARAM_USER(FOLDER,USER,PARAM)
Returns a user parameter in a string

Funprog ADP_TOOL.GET_LEG_FROM_CPY(FOLDER,CPY)
Returns the legislation associated to a company

Funprog ADP_TOOL.GET_LEG_FROM_SITE(FOLDER,FCY)
Returns the legislation associated to a site

Version 7 technology – training 133


Additional tools:
Libraries for multi-folder parameter access
Funprog ADP_TOOL.GET_CPY_FROM_SITE(FOLDER,CPY)
Returns the company associated to a site

Funprog ADP_TOOL.GET_LEG_FROM_CPY(FOLDER,CPY)
Returns the legislation associated to a company

Funprog ADP_TOOL.GET_LEG_FROM_SITE(FOLDER,SITE)
Returns the legislation associated to a site

A dedicated method of the context can be used to initialize a default site


according to the module (local menu 14):
RETVAL=this.ACTX.AGETPRFFCYDEF(this, MODULE, SITE)

Version 7 technology – training 134


Additional tools:
Access to sequence numbers
Funprog ANM_TOOL.NUMERO(ACTX,COUNTER,FCY,DAT,COMP,VAL,ERRMS)
Sets a sequence number value in VAL
Returns [V]CST_AERROR if it fails with an error message in ERRMS

Version 7 technology – training 135


Additional tools:
Methods to handle asynchronous tasks
Call ASYRASYNC.ASYNCTRACK

Creates the dialog box if it doesn't already exist, and displays a message
with the phase name and phase detail. A completion percentage can also
be shown.

Code Type and dimension Contents


CONTEXT ACTX instance Current context.
PHASE_NAME Char Current phase to be
dispayed.
PHASE_DETAIL Char Current detail to be
displayed.
PERCENT Integer Progression percentage
in the range 0-100.

Version 7 technology – training 136


Additional tools:
Methods to handle asynchronous tasks
Call ASYRASYNC.ABORTREQUEST

Checks if the user requests the task to be aborted. It returns 0 if no abort


request was sent, and 1 otherwise..

Code Type and dimension Contents


CONTEXT ACTX instance Current context.

Version 7 technology – training 137


Additional tools:
Methods to handle asynchronous tasks
Call ASYRASYNC.ADDDIAGNOSE

Adds a line in the text displayed in the bottom of the panel, in the
diagnostics list.

Code Type and dimension Contents


CONTEXT ACTX instance Current context.
DIAGNOSE_TEXT Char Diagnose text.
DIAGNOSE_STATUS Integer Status value as
operation return them
(can be
CST_ASUCCESS,
CST_AINFO or
CST_AERROR).

Version 7 technology – training 138


Additional tools:
Methods to handle asynchronous tasks
Call ASYRASYNC.LINKDOWNLOAD

Adds a download link to a file that has been placed in a standard volume.

Code Type and dimension Contents


CONTEXT ACTX instance Current context.
DATA_TYPE Char Content type that describes the format of the
downloadable file.
PATH Char The fila path on a standard volume (for
instance, "[MYVOL]/myfile.tra", whre
[MYVOL] has been defined in the "a
href="../administration-reference/supervisor-
administration-volumes.md">volume table.

Version 7 technology – training 139


REQUESTS & STATISTICS
• Main principles
• Native implementation
• Setup
Requester
Main principles
Design time: the requester is based on meta data in dictionaries
3 functions exist to create queries, that have different descriptions:

“classical” “graphical” “SQL”


requester requester requester
(GESALH) (GESALT) (GESALQ)

A list of tables A graphical design A SQL sentence


and columns in drag and drop with a mapping of
mode the result

Version 7 technology – training 141


Requester
Main principles in V6
Execution time: Display time:
– A script has been generated An inquiry displays the
– Its execution feeds a table (ALISTER) contents of the ALISTER
in the database table

DATABASE Table ALISTER

Execution time
Generation step Data is extracted
GENERATED
when the query and feeds a table
SCRIPT
is validated (ALISTER)
in the database

Version 7 technology – training 142


Requester
V6 implementation
Execution time: Display time:
Every cell of the report creates a line in the Displaying a single line of a
ALISTER table, with impacts on: report reads as many lines
- Performances (massive data insertion) as columns in the request
- Administration (size of temporary tables)
15 lines read
for every line in
DATABASE Table ALISTER the report

Example of a report
that has 15 columns 150,000 lines
and that returns inserted in
10,000 lines ALISTER

Version 7 technology – training 143


Requester
The changes done in V7
Design time: no change in the meta data but…
The graphical requester (based on a flash component) will not be
available in the early adopter version (only with the final V7 version )
“classical” “graphical” “SQL”
requester requester requester
(GESALH) (GESALT) (GESALQ)

generation

generation
generation

generation

generation
V6 code

V7 code
V6 code

V7 code

V6 code
Validation time: the V6 code is still generated for Classic pages use
But a new script is also generated for V7 native mode (only for classical
and graphical requester)
Version 7 technology – training 144
Requester
Main principles of V7
Execution time:
A script has been generated, its
execution generates a JSon file
containing the formatted result:

Execution time
Generation step
Data is extracted
when the query
from database
GENERATED
is validated
andSCRIPT
stored in JSON
(text format) in a file
Display time:
The data is directly pushed
DATABASE to the client
[
{ "cust_id":"JOHNDOE","balance":2000,…},
{ "cust_id":"MARTIN","balance":4000,…},
{ "cust_id":"JIMMY","balance":6500,…},
]

Version 7 technology – training 145


Requester
What brings the V7 mode
The meta data is the same : you just need to revalidate the requests
– It will continue to generate the V6 code so the Convergence requester can be
also be used
– But it generates also the V7 code used by the new requester

The performances are much better


– The data is no more stored in the database, which makes a huge difference (10
to 20 times faster to execute)
– If the estimated execution time is too long, a batch task is automatically created
The restitution is a pure Syracuse restitution
– Usable in service mode (by Word, Excel, and the client)
– Two modes exist : the “flat mode” that unfolds all the data, and the “cube mode”
that unfolds group by group.
– Various options can be used in the URL (option tab in menu items)
– Parameters can be evaluated by using the “dashboard view” (GESAPV)

Version 7 technology – training 146


Requester
Setup a request
The request definition are done in Classic page mode
– GESALH and GESALT are available in classic page mode
The Request execution is defined as a Syracuse menu item:
- type=Query
- Request name=code
- Request level= the depth of
- detail (1=first break only,
2=second break level,

99 = max detail)
- Additional parameters can be
added

Version 7 technology – training 147


Requester
The options available
Options can be added in the Parameter grid on the menu item

Parameter name Possible values Default value Explanation


cube true, false true If true, unfolding a detail will only display
the line that are in the group. If false, it
goes to the next detail with a position on
the first line of the group
forcedExecution true, false false If true, the execution of the request is
forced even if a previous result is
available (takes in account the level of
computation)
frequency 1 to 9 6 Frequency of re-execution since last time
the request was executed or modified.
1=always, 2=every hour, 3=every day,
4=every week, 5=every month, 6=never,
7=every 10 minutes, 8=every minute,
9=every 10 seconds
level 1 to N 1 Current level of data grouping (usually
the same than the request level that
defines wich columns are displayed)
148
Version 7 technology – training
Requester
The options available
Options can be added in the Parameter grid on the menu item

Parameter name Possible values Default value Explanation


linesLimit numeric value 0 (=no limit) Allows to limit, when testing a big
request, the number of lines read in the
database.
timeLimit Numeric value 0 (no limit) Allows to limit, when testing a bug
(seconds) request, the total time spent to generate
line. It doesn’t limit the execution time in
the database, but will stop line fetch.
startRecord Numeric value 0 Used for paging, represent the first line to
display.
startIndex Numeric value 1 Used for paging, represent the first line to
display in the current group in cube mode
requestID UUID (canonical) Null Used by paging links on a given result
instance.
displayLineNum true, false False Displays a line counter on the request

149
Version 7 technology – training
Requester
The options available
Options can be added in the Parameter grid on the menu item

Parameter name Possible values Default value Explanation


recordPerPage numeric value in the NBRREQ user Number of lines displayed for every
(10,1500) range parameter, 20 if request page
not found
count numeric value in the NBRREQ user Identical to recordPerPage
(10,1500) range parameter, 20 if
not found
portview Portal view code Empty string Allows to get default values parameter
defined in a portal view (almost used for
compatibility with V6 portals)
where SData filtering clause None Allows to define an additional filtering
clause that applies on the request. It can
only include columns of the list that have
the range information set to Yes. If the
filtering clause is not the one that has
been used in the last execution, this will
force the re-execution of the request

150
Version 7 technology – training
Requester
Subset of SData where clauses usable
Type Format Example
String Characters between simple quotes 'ABC'

Numeric Ascii decimal representation 3.14159265358


Date @YYYY-MM-DD@ @2014-05-29@
Date time @YYYY-MM-DDThh:mm:ssZ@ @2014-05-29T12:24:32Z@
Parentheses () ( CODE eq 'ABC') and (VALUE eq 3.14)

Operator Description Example


lt Less than PRODUCT lt 'ABC'

gt Greater than VALUE gt 3.14


le Less or equal BIRTHDATE le @1959-05-29@
ge Greater or equal CODE ge 'MARTIN'
eq Equals AMOUNT eq 100
between… and.. Value range ORDDATE between @20140101@ and @20141231@
and Logical and (VALUE eq 5) and (CODE gt 'X')
Version 7 technology – training 151
Requester
Setup a request in a visual process
A request execution in a visual process uses the generic pattern:
{$baseUrl}/CLASS?representation=REPRESENTATION.$facet
Where:
– CLASS is QUERY('REQUEST_CODE‘)
– REPRESENTATION is QUERY~REQUEST_CODE~LEVEL
– $facet is $query

The additional parameters are entered with the syntax:


&parameter=value

Example
{$baseUrl}/QUERY('CUST‘)?representation=QUERY~CUST~2.$query&cube=true&level=2
&displayLineNum=true&where=(CODE gt ‘D') and (AGE between 20 and 50)

Version 7 technology – training 152


Requester
Some limits

The SQL requester is not available


– But the classic and graphical requester now accept views
– So we have to design :
– first a view (development feature)
– Second a classical / graphical request based on the view

Version 7 technology – training 153


Statistics
Main principles (V6)
Design time: based on statistical triggers and statistical codes

Statistical setup
(GESPS1,
GESPS2) GENERATED
Generation step SCRIPT
when the setup TO UPDATE
is validated DATABASE IN
BATCH OR ON
OBJECTS
EVENTS

Version 7 technology – training 154


Statistics
Main principles (V6)
Execution time: based on V6 objects aggregation
When creations or updates happens on V6 objects
Or in batch mode based on data description

Table STAT DATABASE


On creation,
deletion, update
events in
Data aggregation
GOBJET

data is extracted
Display time: from database
A function extracts data from the database
and displays it in a screen
Version 7 technology – training 155
Statistics
Main principles (V7)
Design time: Nothing changed at the design time
But an additional script is generated to display the data:
GENERATED
Statistical setup SCRIPT
(GESPS1, TO UPDATE
GESPS2) DATABASE IN
BATCH OR ON
Generation step OBJECTS
when the setup EVENTS
is validated

GENERATED
SCRIPT
Generation step
TO EXTRACT
when the setup
DATA IN JSON
is validated
FORMAT
Version 7 technology – training 156
Statistics
Main principles (V7)
Execution time: still based on V6 objects aggregation
When creations or updates happens on V6 objects (Convergence)
Or in batch mode based on data description

Table STAT DATABASE


On creation,
[
deletion, update { "item":"H45","sales":7235,…},
{"item":"M23","sales":4958,…},
events in {"item" :"IM01","sales":6490,…},
Data aggregation
GOBJET ]

data is extracted
from database
Display time: and formatted in JSon
The new extraction script sends directly
a JSon feed to the Syracuse interface
Version 7 technology – training 157
Statistics
Setup a stat code
The request definition are done in Classic page mode
– GESPS1 and GESPS2 are available in classic page mode
The Request execution is defined as a Syracuse menu item:
- type=Statistics
- Stat name name=code
- Additional parameters can be
added

Version 7 technology – training 158


Statistics
The options available
Options can be added in the Parameter grid on the menu item

Parameter Possible values Default Explanation Example


name value
DATBEG1 Date in YYYY-MM-DD User parameter 20131201
format DATSTADEB
Range of date for
DATEND1 Date in YYYY-MM-DD User parameter period 1
format DATSTAFIN
DATBEG2 Date in YYYY-MM-DD Previous date 20121201
format range with the
Range of date for
same length as
DATEND2 Date in YYYY-MM-DD period 2
(DATBEG1,DATE
format
ND1)
COMPANY Company code None Display data only SAGE
for a company
FACILITY Site Code None Display data only ANNECY
for a site

159
Version 7 technology – training
Statistics
The options available
Options can be added in the Parameter grid on the menu item

Parameter Possible values Default Explanation Example


name value
Field from Value with the right None Filter on the field value ABC
statistical data type
definition
Portview Portal view code none Allows to get default values MYVIEW
parameter defined in a portal
view (almost used for
compatibility with V6 portals)
$axes Axes definition in None Defines the current level of
JSONURL format display
$slicer Slicer definition in None Defines the current values for
JSONURL format display

160
Version 7 technology – training
Requester
Setup a statistic code in a visual process
A request execution in a visual process uses the generic pattern:
{$baseUrl}/CLASS?representation=REPRESENTATION.$facet
Where:
– CLASS is STATS(‘STAT_CODE‘)
– REPRESENTATION is STATS~REQUEST_CODE~LEVEL
– $facet is $cube

The additional parameters are entered with the syntax:


&parameter=value

Example
{$baseUrl}/STATS('SALES')?representation=STATS~SALES~2.$cube
&DATBEG1=2014-02-01&DATEND1=2014-05-01&COMPANY=SAGE

Version 7 technology – training 161


Statistics
Some limits

Data constitution
– Real time constitution only possible on V6 objects
– On CRUD V7 entity (Syracuse), a batch generation is possible

Data display
– The final zoom on the detail is not supported
– Only the default order of the statistic criteria is available for displaying
the details

Version 7 technology – training 162


USER INTERFACE
• Representation dictionary
• Associated code
Syracuse User Interface
Introduction
The Syracuse technology makes a difference between
– Stateless mode: information is required, set to the client that displays
it. No resource is kept on the server, that is ready for a new operation.
– Stateful mode: we are in a creation or edit operation. The client
manages a draft in which the data being modified is managed, the
server has a working copy storing the classes instance involved. The
protocol synchronizes both.
– Interactions can be defined as links on operations (stateless) or
methods (stateful)
– The user interface definition for a class is done in representations. A
representation has different facets (each of those being a “use case”
for the UI).

Version 7 technology – training 164


Representation management
The representation dictionary
A new meta data dictionary
– With the same type of features (activity code protecting the entity or some
elements)
– With a description on 7 tabs

– With globally the same behavior than a class (it is technically a class that
embeds another class)

A representation has to be validated before it can be used


– The validation performs consistency controls and generates code
– When the underlying classes have been modified, the representation must
also be revalidated

Version 7 technology – training 165


Syracuse User Interface
Introduction to Representations
A REPRESENTATION describes the user interface and includes:
– A reference to a class
– Additional properties (values computed on the fly, fields entered but not stored in a class…)
– A list of usable facets (detail, query, edit, lookup, summary)
– A page organization (sections, blocks, exposed properties)
– Links attached to an element (property, page, array …)
that trigger an operation or a method
– The elements defined in a representation are almost coming from screen/windows dictionary
In the Syracuse user interface, the navigation is done through hyper-text links.
- These links are visible in the interface, either directly or when the mouse comes over an area,
or when a section is unfolded.
- A link can bring to another page that replaces the current page, or open a new browser tab.
Several representations can exist for a given class
- Usable to define “v6 transactions”, but only if the rules are different
- Use authoring otherwise

Version 7 technology – training 166


Representation management
The representation dictionary
The main characteristic of a representation is the class it refers to
– A class code is defined
– An instance code is given to define the path from representation to the class
(noted INST in the next slides)

Additional characteristics
– The type of device the representation is intended for (Desktop, Mobile, Tablet)
– Used for search result flag: defines the page on which the search result link
will go. Only one active flag can be set by representation and type of device.
– Activity code and module
– Two V6 function code:
– The first one defines the function used to determine the authorizations (the
fuser function profile refers to functions)
It is recommended to have a function code here, even if it is a pure V7 page
– The second one to define the Classic page link if any exists.
Version 7 technology – training 167
Representation management
The representation dictionary

Managed behaviors
– Defines the functions available in CRUD mode:
– Creation, Update, Deletion
– Excel and Word Reporting / merge
– The second one to define the Classic page link if any exists.
– The behaviors that are selected will activate the different facets

Version 7 technology – training 168


Representation dictionary:
Facets

A facet is a use case for a representation


– In the URL, the facet is sent :
…/ENDPOINT/CLASS?representation=REPRES.$facet
– The most common facets are defined here:
Representation Description
representation for a summarized page (equivalent of File/Properties link
$summary
in v6 objects)
$query representation for a query page (equivalent of the left list in v6)
$details representation for a details page.
$edit representation for an edit form.
representation for a lookup box (equivalent of the selection box called by
$lookup
F12 button)

– Some other technical facets exist in URL

Version 7 technology – training 169


Representation management
The representation dictionary

Collections
– Defines:
– additional collections that are only used for UI purposes
– Collections defined in the class only if their characteristics changes
– The collections found in the class are embedded with the class
without need to re-declare them.
– The columns present in this collection list are the same than for the
classes,
Scripts
– List of hierarchized scripts that will be called exactly in the same way
than for classes. Their name is REPRES_Rxxx, where xxx can be
STD, SPE, VER
– The same events (plus additional ones) will be available in the scripts
Version 7 technology – training 170
Representation management
The representation dictionary

Properties
– Defines additional properties used only for user interface
– The same type of information than for the property class is entered.
– No child instance are allowed here
– It is impossible to add properties in a collection that has been defined
in the class (no extension of properties in a collection managed by the
class)
Keys and Parameter definition grids
– Filled according to the data type. The parameter values must be filled
with the same restrictions than for classes (no computation, only
constants and properties in the representation / class hierarchy are
allowed)
Version 7 technology – training 171
Representation management
The representation dictionary

Methods array
– Allows to define dedicated methods
– The same type of information than for the class is entered, except that
no operation check-box is available.
– The reason is that in a representation, we cannot be stateless. We
have here operations linked to the UI that have to be stateful.
– A unique parameter definition array is present here (no key array, for
the same reason).

Version 7 technology – training 172


Representation management
The representation dictionary

Methods array
– Allows to define dedicated methods
– The same type of information than for the class is entered, except that
no operation check-box is available.
– The reason is that in a representation, we cannot be stateless. We
have here operations linked to the UI that have to be stateful.
– A unique parameter definition array is present here (no key array, for
the same reason).

Version 7 technology – training 173


Representation management
The representation dictionary

Blocks and sections array


- Describes how the sections and blocks are organized by default (but
this can be changed by page personalization).
- N sections, every section can contain N blocks
- The section and blocks are ordered
- Activity codes are present to protect them or the make them
unavailable
- No code can be attached to sections and blocks:
- Additional sections and blocks can be added at authoring mode
- Fields can be moved from a section or block to another
- Hiding a block or a section can not be done by a program. But
hiding all the property of a block will hide the block.
Version 7 technology – training 174
Representation management
The representation dictionary

Filters array
- Defines the list of filters that can be used for the current representation.
- Filters defined in the class can be selected, but additional filters can be
created for the representation.
- A filter that is set as mandatory will always be applied on the query.
- All the other filters present in this list are used in the query facet
- Links will be present on the right side: clicking on such a link will apply
the filter in addition to the mandatory links if we have some.
- If at least a not mandatory filter is present, a “No filter” link is present.
Sort order / Index descriptor
- Defines the order used for the query (the first index by default)
- If no index is given, a list a fields can be given (format F1+F2-F3…)
Version 7 technology – training 175
Representation management
The representation dictionary

The properties that can be presented on the UI are:


- The properties defined in the representation ( syntax: PROPERTY)
- The properties of the main class instance (syntax: INST.PROPERTY)
- Any property of any child instance (syntax INST.CHILD.PROPERTY)
A property must have an unique alias
A property is placed by default on a block (in a section)
Information linked to the properties
- Check boxes define on which facet every property is present
- A property can be displayed only on Edit facet (check box)
- A property can be invisible (technical property for links, for example)
- A property can be sent as a filter (Filter check box) with &ALIAS=value
syntax on query facet
- A property can be sent as a default value (Entry parameter checkbox) with
&ALIAS=value syntax on a detail or edit facet (for creation purposes)
Version 7 technology – training 176
Representation management
The representation dictionary

Defines the links available at any level of the representation


- hyper-link present on the page (directly or by an icon opening a list of links)
- Replaces all the buttons, menus, or controls presents in v6 on windows and
screens

A link has a type and optionally an anchor to define its place:


- Page: The link is present on the right panel. No anchor value is given.
- Record: The link is present on the line of the query facet. No anchor value is
given.
- Collection line: The link is present on the grid line; the anchor is the
collection name
- Property: The link is present on a property; The anchor is the property path.

Version 7 technology – training 177


Representation management
The representation dictionary

The Link tab presents the links


- With a first selection on the type of link (and optionally the anchor)
- With a Generated checkbox that also displays the links that are generated
from data types
A link can be:
- Active or not (useful to deactivate generated links)
- Replaced (if generated link) by another link (especially useful for the default
“detail” hyperlink that is done by click on the field content, or to change the
selection link available through a magnifying glass icon)
- Present on the different facets (checkboxes)

Version 7 technology – training 178


Representation management
The representation dictionary
Type of links and associated characteristics
- Representation:
- Calls another page defined by the representation code and the behaviour
(create an entity, modify an entity, display the detail, delete an entity,
display the list, display summary, display in Excel…)
- A query representation link can be embedded from a detail link
- Additional parameters and or keys can be necessary
- Method / Operation:
- Calls a method defined by an instance (if on another instance than the
current one) and the method code
- The key value is requested on an operation
- An operation link can be asynchronous
- Convergence: calls an X3 function in classic page mode
- Other: calls an URL. This URL can include properties of the representation
with the following syntax : {ALIAS} (replaced dynamically by the client)
Version 7 technology – training 179
Representation management
The representation dictionary

The Menu tab organises the global links


- With a list of menus that can be linked to a sub-menu
- Defined by a code, a description, the parent menu, an activity code
- A sorting order is also given
- With an array that defines the default link per facet
- This link is presented in blue in the user interface
- If not given default rules exist
- Create on the query
- Edit on the detail
- Save on the edit

Version 7 technology – training 180


Writing code in representations:
Associated code
What kind of code has to be placed in representation?
- Code that makes the user interface more friendly, for instance:
- Hide dynamically elements that are useless in a given context.
- Perform more dynamic controls (trigger global controls before).
- Code associated to links:
- To perform dedicated operations .
- To call standard methods.
Main principles:
- Don’t consider that an operation hidden by the UI cannot be called:
- It can be called in web service mode.
- It can even be called by through an URL in the browser.
- Don’t forget that the order in which the data is entered can be changed by
authoring and vary for every user.

Version 7 technology – training 181


Writing code in representations:
Associated code
The way the code is executed with a representation is the same
- In every script, $OPERATION, $METHODS, $EVENT and $PROPERTIES
label exist to catch the different types of events
- The events are the same than on classes, but with an additional level of
nesting
- Additional events or capabilities can exist depending on the context

Version 7 technology – training 182


Writing code in representations:
Standard methods
At validation of a representation, the supervisor generates scripts that implement the
methods found in the associated class:
– AREAD(KEY), AINIT, AINSERT , ADELETE, AUPDATE

The other standard methods are also available, such as


– ASETERROR(PROPERTY,MESSAGE,[V]CST_XXX) ADELETEERROR(PROPERTY)
– ASETATTRIBUTE(PROPERTY,ATTRIBUTE,VALUE)
– ADDLINE(COLLECTION,POS)
– ADELLINE(COLLECTION,POS)
– AGETINDBYLINE(COLLECTION,POS)

Version 7 technology – training 183


Writing code in representations:
CRUD event nesting
The CRUD events are called at different level:
Header (representation):
- Called once for the instance, CURPTH is empty
- CURPRO: current header property (if rules executed).
Header (class):
- Called 2 times : in class associated code, then in representation code
- for the class code, CURPTH is empty
- for the representation code, CURPTH is the name of the class instance
- CURPRO: current header property (if rules executed).
Lines:
- called 3 times : in line child class associated code, in class associated
code, in representation associated code
- for every line instance, CURPTH gives the path (empty at line associated
code, LINE for class associated code, CLASS.LINE for representation
associated code)
- CURPRO: current line property (if rules executed).

Version 7 technology – training 184


Writing code in representations:
Query Events

Events Called Context


AQUERY_DECODE_CRITERIA_AFTER Used to define the columns present in the query.

Used to define the link key to be read (database table,


AQUERY_PRIMARYKEYS_AFTER other pseudo-table, or link opened with
[LNK]abbreviation).

Called after the decoding of the query URL. Gives


AQUERY_OPEN_AFTER
access to data and parameter of the query.

AQUERY_CRITERIA_AFTER Used to refine the query criteria

Used to define the "Link" that is used to retrieve the


AQUERY_JOIN_AFTER
data.

Executed on an instance (this is available). Values of


AQUERY_TRANS_AFTER
the lines in the query grid can then be assigned.

AQUERY_CLOSE_AFTER When the query is closed.


Version 7 technology – training 185
Writing code in representations:
Example of code called at interface level
# Every time a line is deleted, we need to display the remaining credit
$EVENTS
Case CURPTH
When "ORDER.LINE" : # Method on the LINE child instance of ORDER instance
Case ACTION
When "ADELLINE_AFTER"
Gosub UPDATE_CREDIT_LIMIT
Endcase
Endcase
Return

# Happens when a property has been modified on the line


$PROPERTIES
Case CURPRO
When "ORDER.LINE.UNITPRICE", "ORDER.LINE.QUANTITY“
Case ACTION
When "PROPAGATE"
Gosub UPDATE_CREDIT_LIMIT
Endcase
Endcase
Return

Version 7 technology – training 186


Let’s come back on UI events:
stateless mode

Query execution on server


A query page is displayed
Selection and sorting criteria can
stateless Click on a detail be refined, and paging done
mode link
Read instance on server
A detail page is displayed
Click on another detail link
(zoom, “tunnel”…)

Click on a create link Click on an edit link Page display

User action
An edit page is displayed
Events available

Version 7 technology – training 187


Let’s come back on UI events:
stateful mode
Click on a create link Click on an edit link

INIT event
Updates done on the instance
An edit page is displayed (triggers control, propagate rules…)
modified properties are sent back

Stateful
mode Input done on page : Modification
Click on the save link returned

Global control are done, if errors, they are returned


Update is performed if everything is ok

Page display

User action
Return to stateless mode (query or detail)
Events available
Version 7 technology – training 188
Writing code in representations:
Attributes Handling
We still use the ASETATTRIBUTE method
Fmet THIS.ASETATTRIBUTE(PRO,ATTRIBUTE,ATTVAL)

Parameters of ASETATTRIBUTE
- PRO is the property name
- ATTRIBUTE is the attribute name:
- "$isHidden" : set to "true", means that the field is invisible
- "$isDisabled" : set to "true", means that the field is greyed
- ATTVAL is the value that can be "false" or “true"

Version 7 technology – training 189


PAGE PERSONALIZATION

• Main principles
• User interface
• Import/Export of
personalization
Page personalization
Main principles
BROWSER WEB SERVER SAGE ERP X3
(NODE.JS) SUPERVISOR
A prototype is requested DICTIONARIES
A link to a new page is
triggered GENERATED
SCRIPTS
Is there a
The page layout is No personalized
page for the
displayed user and A prototype is sent
role

Yes
The personalization applies
on the prototype
The page is filled with DATABASE
data The corresponding data is sent CLASS LOGIC
Version 7 technology – training 191
Page personalization
Main principles
–The page personalization allows to create several layouts
for a given representation and facet.
–This personalization is stored in the administration
database (MongoDB)
–This layout is stored in differential mode. When updates are
done in the repository, the tool is almost able to continue to
apply the personalization.
–A personalization can be dedicated to a user, an endpoint,
a role.

Version 7 technology – training 192


Page personalization
Database storage
–The page definition entity stores the personalized pages:

Version 7 technology – training 193


The Version 7 web UI
Personalization mode : let’s tailor the page
– Accessible with the icon
– Moving fields, hiding fields, reorganizing sections, blocks, columns
– In WYSIWYG mode, by drag and drop

FIELDS CURRENT
PAGE LAYOUT AND ORGANIZATION
LIST LEVEL

Version 7 technology – training 194


Page personalization
Transfer is done by extraction from MongoDB
–Use the Personalization management function

–Create a Personalization management

–Launch the export that creates a Json file


Version 7 technology – training 195
Page personalization
Integration is done by using import
–Use the import profile function

–Json file can be imported

Version 7 technology – training 196


Mobility
Main principles
On mobile or tablets, the same code runs:
- But the representation is checked mobile
- Less fields are usually present on a page
- Default values can be defined at representation level
Interactivity mode is not the same
- Exchanges are done with the server only at init time and when a save action is
executed
- Links can of course trigger some actions
Main principles: split the UI and then business logic in small chunks
- For instance, for an order, have a basket on which lines can be added
- This can impact the design of the application logic

Version 7 technology – training 197


MOBILITY PRINCIPLES
Mobility
Main principles of mobile development
The development uses exactly the same code and entities
- Script is the same, classes are identical, but representation are dedicated
- Interactivity is different
- Gadgets, mobile dashboards and applications have to be created instead of
menu items
Browser Version 7 Version 7
Web Server App Server

Mobile Pages Query & detail


Client page
Menu items Classes and
Representations
Personalize
HTML5 Database

Version 7 technology – training 199


Mobility
Mobile features
A mobile representation can use the following standard features:
- The query facet
- The details facet
- The edit facet
- Actions defined on queries
- Links present on details or edit facets
- Image input can trigger the camera to take a picture
- Phone number directly has a link to make a phone call
- Email address has a link to send an email
- Input on grids are done with a dedicated page by line
- Search is done on the entity
On Surface tablets, additional features are available
- Live tiles, camera + pen to tag the pictures, hand writing, Cortana voice
recognition…
Version 7 technology – training 200
Mobility
Additional features brought
Local storage : HTML5 database used for
- Favorites (used for selection)
- Drafts (i.e. Pending data input on a representation)
- In case of errors
- In case of disconnection
- Resynchronization
- Disconnected mode:
- An orange bar shows the disconnection
- A download of data can be done in the cache before

Version 7 technology – training 201

You might also like