Professional Documents
Culture Documents
Workshop Agenda
• Part 1 – Introduction to Class &
Representation
• Part 2 – Show case: Develop a
simplified sales order management
At the end of the workshop you will be able to:
• Create and use a class, a representation and its mobile app without
source code to write
• Develop scripts to handle all rules, events and methods part of the class
management and its behavior
Note: patches do not include authoring components because they are administration module
elements (menu items, personalization, home pages, mobile apps,…), but only development
features (dictionaries, scripts,…). Authoring components are deliverable by json files.
Part 1 – Introduction to
Class & Representation
• Class dictionary
• Representation dictionary
• Mobile representation
Part 1- What you will
learn
• To create a mobile
application from a
representation
Meta Data
Sage X3 is using meta data description. This means that the database structure, the entities
managed, their methods, the UI description, the parameters, the navigation is stored as
administration data in dictionaries. The business logic rules are written in scripts using a very
simple language.
This is stored in dictionary tables. A standard dictionary is supplied, but every repository
(folder) can have modifications and additions managed by activity codes.
This makes it very easy to customize a folder by adding elements in the dictionary and
additional scripts.
The transition between versions is also simplified with meta data (the dictionary structure
changes are managed by the platform).
A powerful set of tool (patching system) allows to deliver consistent sets of modifications made
in a development environment to customers.
The partners have the same development tools than the Sage internal
developers. They can write additional functions, describe additional tables, add new
columns in standard tables, create new scripts that interact with standard one
through entry points, create new pages or update existing pages…
PROPERTIES
Defines the business logic
CLASSES (what are the consistency
METHODS / controls done, which
(If persistent)
OPERATIONS : operations are possible)
Creation When this is done, the entity
• Main table
Read can be managed by web
associated
Update service, by program, by user
Delete interface)
PROPERTIES
REPRESENTATIONS Defines the UI (how and
• Device associated ORGANISATION where the fields appear on
• Class used (Sections, Blocks) the page, how can we
navigate from a page to
• Available behaviors NAVIGATION another)
(Filters, Links)
Simple lead management & its mobile app
Lead
manageme
nt
Table dictionary – YLEAD table
Database tables are described in the table dictionary tabs.
The header defines the table code, a description, and an abbreviation used
in scripts.
An optional activity can be defined in the general tab (it can be activated and
deactivated), but also as a marker for a bespoke or vertical module (when it starts
with X,Y or Z) to protect the dictionary elements against standard updates.
Note: Standard activity codes are used to configure the folder , for instance, fields used for a
given legislation, or options that are used only in some activities (lot or serial number
managements for instance). An activity code can be defined at header or detail level of a
dictionary. The lowest level is usually the best: you protect only a field if you add a specific field
in a table, so you will be able to benefit from further modifications on a table; but protect the
table if it is completely specific.
Table dictionary – YLEAD table
The first tab defines the management and delivery conditions of the table, and additional
technical features
Table dictionary – YLEAD table
5 technical columns
are automatically
filled by standard
methods that
updates the table
On the third tab, we can define the indexes used to access the table
The fourth tab Audit is not used here. It allows to create triggers on a table in
the database in order to track data changes in the current table by filling audit
header and detail tables (AUDITH and AUDITL).
Note: The data dictionary is independent from the database used (SQL Server or Oracle). The
application we will write is completely independent from the database, the operating system,
and even the device, and this is important, because your investments are protected and can be
use on any platform supported the customer is accustomed to.
Class dictionary – YLEAD class
A class describes an entity with its business rules. Here, we have a very simple definition
(only 4 tabs are filled in this case):
The class is
persistent
(values of an
instance are
stored in the
database on the
main table
YLEAD), has the
same activity
code (YOH)
The property tab contains approximately the same columns that for a table, but additional
information is located here, especially the access code (to protect the property from access
in some cases), and the search policy (searchable flag, additional filter category)
The mapping table defines the database tables used for the persistence of data. Here, a unique
table (already defined in the General tab) is used, and the database updates will be done by the
engine on read, creation, modification and update.
Note: If this check boxes are not filled, the developer can create the code associated to the
persistence of data by himself. This can be the case for some dedicated classes where the
persistence is done in another way.
Data type dictionary – BPC type
Note: As we can see here, declaring a reference is simple. The reference will inherit
automatically from all the features defined in the class. For instance, if the class defines filters,
the filters can be selected when we define the reference in a class (in the parameters list).
Representation dictionary – YLEAD representation
The representation describes an interface class that is used to access to the data.
Properties and Methods describe additional properties and method defined on the representation
and not on the class (usually for UI purposes). These tabs are not filled here.
The Organization tab describes the default layout (in sections and blocks) and additional features
(filtering options). Here we define only one section and one block
Representation dictionary – YLEAD representation
The displayed property tab describes, for every facet, the different properties that are
displayed and/or entered:
Property path: here YLE.xxx means that this is a property from the main class instance
Unique alias
For every facet, you can define if the property is present or not, if it is Visible by default or
not (this can be changed by user personalization), and if it can be entered
Control, patching and help
Part 1
- Generated links
- Property level
- Lookup link
- CRY parameter
- Filter P
- Parameter value
Introduction to link on representation
Hands on - Result
Only the customer from the selected country are displayed in the lookup
Mobile representation – YLEADM representation
That’s all !
Note: that the behaviors and the properties published can be different if needed.
Frequently, a mobile page is simpler than a desktop page.
Mobile application creation
Data type
YDI
Table dictionary – YORDER & YLINE tables
A meta data dictionary that describes the tables present in the database.
• The table code is the name of the table created in the database
• The abbreviation will be used to identify table elements later
• A simple description (translatable text)
Four tabs describe the characteristics of the table, but we will only describe
some characteristics on the three first tabs.
Table dictionary – YORDER fields
Main info : column name, data type, length, description, mandatory flag,
additional info that depends from the data type.
Table dictionary – Local menu 1001
The column ORDSTA in YORDER table has been defined as a local menu
(#1001). This corresponds to an enumeration of choices of different values and
messages. The number column corresponds to the value of the ORDSTA field,
and the Message to the label displayed in the user interface.
A local menu can be translated in any language available in the user interface. In
the user interface, it can be see as a combo-box or a set of radio buttons.
Table dictionary – YLINE fields
Main info : column name, data type, length, description, mandatory flag,
additional info that depends from the data type.
Data type dictionary – Options on YDI type
YORDER table: 3
indexes are given (one
as main reference, the
two others have 2
components)
This tab describes methods (stateful) or operations (stateless) that can be used on
a class instance.
• The TOTAMOUNT method computes the total amount of the order by summing
the amount of all the lines.
• We define also the DISC_ERASE method, that will be called from the
representation, to reset to zero discount on lines.
• Additional parameters and/or keys (for operations) can be defined as well for
every method or operation in the two additional grids present on the tab.
Class dictionary – YORDER class – Standard methods
This tab allows defining the standard methods that are allowed to the
class. A persistent class can usually use all the CRUD method (Creation,
Read, Update, Delete)
Class dictionary – YORDER class - Properties
This tab describes how the persistence operations (CRUD methods) are managed:
• Header level: main table and operation allowed are defined
• Collection level: join description, key values for join, operation allowed (class
management checkbox means that the child class operations are used)
Class dictionary – YLINE class - Detail
For the line, the structure is simpler: no collections, only the columns
from sales lines (including technical ones), no dedicated method, the
same CRUD methods, a unique “header-type” mapping:
Class dictionary – Adding controls with scripts
As soon as the two classes are defined and nested, the CRUD method are available and
a service can call them to create sales orders.
But usually we have to add some pieces of code to perform controls or to define default
values.
This is done by adding references to scripts in our classes. The scripts are defined in the
first tab of the class. Several scripts (standard, vertical, specific) can be added and their
execution order can be defined:
• On lines, we have a unique specific script
• On the header, two scripts are present, but the first one is the only one that is
necessary for the moment (the second will implement additional features):
Testing and practice
Step 1
• Execute QLFYOH_1 script after the YORDER and YLINES classes creation to
test the classes are correctly created
• Install patch SRC_KT_DEV_EXERCISE-STEP1 with incomplete scripts
• Complete the source code YLINE_CSPE to add:
Control of the unit price
o Set an error if unit price < 0
Compute the price after unit price is changed and ok
Write the subroutine LINE_PRICE
o Price = quantity * unit price * (1 – discount/100), rounded 0.001
• Complete the source code YORDER_CSPE to add:
DISC_ERASE method
o Loop on LINE collection to reset to zero the discount property
Call to TOTMAOUNT method after control in creation and update event
YLINE_CSPE script - rules
This script implements consistency rule applying on the lines.
At $PROPERTY label, the rules can be scripted:
• this is the current class, this.PROP is the property PROP
• [L]CURPRO is the current property, [L]ARULE is the rule
The label $AOPERATION is used to handle the operation (stateless) and is not
used here.
TOTAMOUNT method
Use the sum operator on PRICE
properties in the LINES collection
(range from 1 to the maximum
number of lines given by maxtab)
DISC_ERASE method
Performs a loop on all the lines
and sets the discount to 0
YORDER numbering : YOH sequence number
The YOH sequence number code corresponds to a set up function that defines
sequence numbers:
• Execute QLFYOH_2 script after the controls added in the class script
• Class as a service
• Log management
• Representation and nested class
• Links for method
• Filter/Entry Parameter
What you will learn in
Part 2 - Step 2
Select
• sales sites (SALFLG=2),
• Customers (with a repetition of
customers following *1 pattern code)
• Products
The authorization function is to manage the X3 access right of the user regarding the rules
defined for the associated function.
User interface: YORDER representation
A representation has several facets (use cases) depending on the displayed properties on
each ones, manages behaviors that can be related to facet (Edit facet : Creation, Update and
Delete) and is associated to a device type.
User interface: YORDER representation
This first representation has no additional property nor method. The next tab to be filled is
the representation, that will generate a default layout based on sections containing blocks
User interface: YORDER representation
The displayed property tab defines the properties available in the user interface, for the
different facets. A direct selection can be done from the class.
.
.
.
.
Can the property be For every facet, you can check boxes to define if
List of properties with their path: all
a filter and can its the property is present on it.
their characteristics are displayed,
value be sent in the Additional properties (enterable, hidden, visible
including activity codes
URL? by default) are present
Link on properties
The Link tab defines the navigation links available on the UI. A link can be assigned to a
property, a page, a record, or a collection line.
Here we describe a link from ORDNUM field in the query facet to the detail (by default, the
link is available from an icon on the line, but here it is a detail link)
Popup view
of the link
definition
Link to trigger a method
Here we describe a link from the page level only available from the edit facet. This link will call
the DISC_ERASE method from the YORDER class.
The link will appear as a button on the right side of the UI.
Popup view
of the link
definition
User interface on a desktop page
It is now possible:
• to query orders
• to create a new order
• to display an order
• to update an order
User interface on a desktop page
The link button to erase discount on lines is available on the edit facet.
Link management: YLEAD/YORDER representations
We can add a very simple but useful feature: have a link that goes from the leads to a page that
lists all the orders created for the customer.
If you look on the representation YORDER (that will be explained in the next steps), you might
see that Filter P and Entry P fields are set to yes for the customer:
Now we can add to the lead representation, in the link section, at the record level,
for the facets query and details, a link to the YORDER representation :
We can now validate the representation, and the links appears directly at the list level and on
the right bar of the details:
Patching & help
Steps 1 & 2
• Execute the YRANDOM script to generate orders (if not already done)
• Class as a service
• Log management
• Representation with child
class and collection
• Setup and functioning of the
navigation links of the
interface
Step 3 – Orders business logic improvement
Class interaction, additional controls and methods
Part 2 – Step 3
User interface
YSHIP table YSHIP class YORDERSHI_CSPE
Restrict updates on shipped orders YSHIP
• CONTROL on customer, quantity, representation
YSHIPLINE YSHLINE shipped quantity
table class Prevent line shipped lines deletion
Shipment status according to quantities
YSHIP
YORDER
Use creation method on YSHIP class
class
Use update method on YORDER class
Table dictionary – YSHIP table
This table is simpler than the order:
5 fields +
5 technical fields
5 fields +
5 technical fields
The properties present on the shipping class are the property present in the main table, plus a
collection of shipping lines
Class dictionary – Shipping class (YSHIP)
The properties present on the shipping class are the property present in the main table, plus a
collection of shipping lines
If we consider that orders can be shipped, we have to add consistency controls and methods:
• ORDER STATUS should be automatically set according to the shipped quantities on the
lines
• FILTERING ORDERS by their shipment status must be possible
• CONTROL ON LINE DELETION: A shipped line cannot be deleted
• QUANTITY MODIFICATION: When modifying an order, the ordered quantities cannot
become smaller than the shipped quantities
• CUSTOMER MODIFICATION must be impossible on a shipped order
• SHIPPED QUANTITIES MODIFICATION must be impossible directly, but only in a
dedicated shipment method (OPERATION property of the YORDER class)
• A SHIPMENT METHOD will be created, and the corresponding written code
To implement these features, we will add an additional script to the YORDER class.
This script is called YORDERSHI_CSPE. The script YSHIP will manage the creation of
a shipment document from an order.
Additional features on sales order class (YORDER)
To manage additional controls and shipment operation the YORDER class has to be modified:
an additional script in the general tab and additional operations in the methods tab.
Filtering condition on sales order class (YORDER)
The miscellaneous tab is notably dedicated to filters. Here, we declare for instance legislation,
company, site, access code properties.
These properties are used to filter the data according to read, write, execution rights granted to
every user on legislations, companies, sites, and access codes.
A list of applicative filters defined by a code and a condition can also be defined.
Testing and practice
Step 3
• Execute QLFYSH script after the YSHIP and YSHLINE classes creation to test
the classes are correctly created
• Install patch SRC_KT_DEV_EXERCISE-STEP3 with incomplete scripts
• Complete the source code YORDERSHI_CSPE to add:
Control of the delivred quantity
o Set an error if delivered quantity is modified and OPERATION property is
not « SHIP »
Event to add a line
o Set an error if order status is « invoiced » to not allow the line addition
• Complete the source code YSHIPALL to add:
Call to SHIP operation set on the YORDER class
Set a message according to the return value of the SHIP operation
• Execute QLFYOH_3 script after the advanced controls are added in the
scripts
YORDERSHI_CSPE script
A technical property called OPERATION has been added in the class. On a line
property, we access to this property through the this.APARENT path.
The delivered quantity can only be changed if OPERATION is equal to "SHIP".
The shipping operation will be implemented with the SHIP routine in the YSHIP script
The SHIPALL operation is the SHIPALL routine in YSHIPALL script
Miscellaneous declarations
Let’s use the AREAD method to read the order and fill this instance
If the order doesn’t exist or is not shippable, raise an error (ASETERROR method) and exit
DLVNUM assignment
Header values
Loop on order LINES collection. Only the lines with QTY>DLVQTY are selected
Variable declarations
Read the current order (the operation is stateless) and raise an error if not found
Check errors and create the right log lines in the trace file
End of the loop: close the log and display a download link
The shipment representation (YSHIP)
The shipment representation is very simple: it doesn’t allow any CRUD operation except
reading, it has two sections (header/lines) with a block in each, it has no additional method, no
special link, and the displayed properties are the shipment header columns plus the shipment
line collection properties:
The shipment representation (YSHIP)
• Representation properties,
methods & script
• Embedded link
The representation is the same than YORDER, with just some differences.
A script is associated
to implement
additional actions
The representation is the same than YORDER, with just some differences.
The representation is the same than YORDER, with just some differences.
• SHIP_DISPLAY is a link that displays the query associated to the YSHIP representation .
The link type is embedded and present on the detail facet: this allows to display the list
of the shipment associated to the order. The current order is sent as a parameter to the
query (the order number is defined as a filter property on the YSHIP representation)
User Interface: YORDER1 representation
Links (2)
The representation is the same than YORDER, with just some differences.
First rule: every time a price is modified, re-compute the total amount. In the class,
this is only triggered before creation or update, for performance reasons. But if we
want a good interactivity of the UI, it is better to implement it as an interface rule.
Second rule: assign contacts properties in the representation every time the customer is modified
Assign also contacts properties in the representation after loading the order
The call (present on the previous page) sends parameters that are either direct
properties from the class instance (“this” is the order, CURPTH is "YOH"), or
elements from the representation (which is the parent instance accessed with
APARENT pointer):
YORDER_RSPE script (methods and operations)
This last section implements the methods and operations. Here, we have only
one method, RTZ_DISCOUNT, that uses the label previously defined in this script
Enhanced User Interface
The query displays the order lines and all the links are present.
Header section
Lines withwith
section 2 blocks
(General ainformation,
onlysection
Total grid of
Embedded Contact)
lines
shipping list
• To manage an enhanced
representation for mobile
A link has been added on the detail facet. It links to a mobile representation
YLEADM that lists all the leads for the customer (the parameter BPCNUM is set
with the order customer)
Mobile representation
Links
A link has been added at page level. It links to a mobile representation YSHIPM that
lists all the shipments of the order (the parameter ORDNUM is set with the order
number.
YORDERM1_RSPE script – part 1
This script manages default values used for display and/or input. We work here in service
mode: the default values can only be assigned at the end if no value has been entered,
except if they are at the document level and if they can be assigned independently from
other computed values
The comment depends on the user (given by the context this.ACTX) and
on the current date (date$)
YORDERM1_RSPE script – part 2
Events are here defined at the 3 levels:
• Representation for query event (Join definition to get data from tables not described in the
class; transfer of data read to representation properties)
• Order Class level (default values defined after data entry)
• Lines level (default quantities after line insertion)
On detail facet, fill the country, the customer risk and the contact information
Default values on lines computed at the end if no value has been entered
YORDERM1_RSPE script – part 3
Default values are rather simple, but a little bit different than before
Default company
assignment (the
first company if no
company found
for the user)
YORDERM1_RSPE script – part 4
• Mobile enhanced
representation
© 2016, The Sage Group plc or its licensors. Sage, Sage logos, Sage product and service names mentioned herein
are the trademarks of The Sage Group plc or its licensors. All other trademarks are the property of their respective owners.