You are on page 1of 25

Sage ERP X3

Development Part 2 (GAP V6.5 to V7)

Exercises level 2

This manual addresses Version 7

Reference: X3DVP2v7.1p5EXMSA1.0

22 01 2014
© Sage 2015
This document is the exclusive property of Sage and/or all of the Sage Group affiliates and is
protected by the Intellectual property Code, copyright laws and international treaties.
Any partial or total reproduction of this document is strictly prohibited.
Anyone not complying with these provisions shall be guilty of copyright infringement and will
be liable to criminal penalties provided by the law.

Page 2 of 25
Table of contents

1.0 Preamble 4
1.1 Introduction 4
1.2 Audience 4
1.3 Prerequsites 4
1.4 Library management functionalities 4

1.0 Tables 6
1.1 Activity code XX01 6
1.2 Local menus 6201, 6202, 6203 6
1.3 Tables XLMBOOK, XLMMEMBER and XLMLOAN 8

2.0 Data Classes 10


2.1 Data Classes 10
2.2 Data types 12

3.0 Data Classes Scripts 13


3.1 Code to handle Properties 13
3.2 AXUNIT test 13
3.3 Code using events/methods 14

4.0 Representations 15
4.1 Representations 15
4.2 Adding the representation on the UI 18
4.3 Representations Script 21

5.0 Additional Services 22


5.1 Logging operations 22
5.2 Profiling 22

6.0 Results of the Development Processes 23

Page 3 of 25
1.0 Preamble

1.1 Introduction
In order to show you the new way of development on V7, we will create a basic Library
Management System application, as the basic use of a library for ‘borrowing from a
collection’ (i.e. not a ‘programming language’ library) is common to all, whatever one’s
nationality or country.

This document should be used in conjunction with other Sage ERP X3 documentation.
Links to relevant documents containing more detailed instructions on how to develop
Sage ERP X3 with the Syracuse technology are listed in each Where can I find out more?
section.

1.2 Audience
The intention of this document is to assist those with limited knowledge of the Sage ERP
X3 Syracuse platform to develop and implement a simple application in Syracuse using
recommended practices.

Development (Use) cases in the Appendix list development processes common to many
applications that will be used in the development of the basic application.

1.3 Prerequsites
Access to the following tools are required before starting the Library Management System
project:

 A central development environment:


– V7 VM
 ‘dev-doc’ GitHub wiki (https://github.com/Sage-ERP-X3/dev-doc/wiki).
 Mobile device emulation software

1.4 Library management functionalities


To develop, set up, use and administrate a simple ‘library’ some basic business processes
are needed. The business solution must allow you to set up a library that contains books
that can be borrowed by members registered with the library. It must address the stocking
of the library with books, the registering of library members and the day-to-day processes
of borrowing and returning books such as keeping a list of reservations, ordering new
books and charging members that return their books after a set return date; the platform
solution must consider factors such as providing searches, filtering and reporting.

Example requirements:

 As a librarian I want to add/amend books in the Library Management System.

Page 4 of 25
 As a librarian I want to be able to add/amend members in the Library Management
System.
 As a library member I want to be able to renew a book using a mobile device.
 As a library member I will need to return borrowed books.
 As a user I want a book that does not currently exist in the Library Management
System.
 As a developer I want to display warning and error messages to users.
 As a developer I want to filter LOOKUP representations.

In order to do this we will follow the steps below :

1: Create local menus 2: Create data tables

4: Create representation 3: Create data classes


classes

5: Create menu items to 6: Add menu items to the


open representations navigation page

Page 5 of 25
1.0 Tables

1.1 Activity code XX01


Firstly, an activity code has to be created.

Code Title Key Field Details

XX01 Library management  Type: functional

 Active: checked

1.2 Local menus 6201, 6202, 6203


Book and member property types that could be defined in a Local menu are as follows:
– Books:
o Genre – Action; Adventure; Classics; Cooking; Fantasy; Humour; Horror;
Mystery; Poetry; Romance; Sci-Fi; Travel
o Status – Available; On loan; Damaged; Lost
– Members:
o Type – Adult; Child; Student
o Status – Active; Inactive (Local Menus 1)

Using the TXT function (Development > Data and parameters > Tables > Local menus -
messages) in the Windows Safe X3 client, create the Local menus, as follows:

Page 6 of 25
Title /
Code Key Field Details
Description
 Local menu: Select (yes)
 Activity code: XX01
 Code. Numeric (incremental)
 Message. Genre:
– Action
– Adventure
Library Book – Classics
6201
Genre – Cooking
– Fantasy
– Humour
– Horror
– Mystery
– Poetry
– Romance
– Sci-Fi
– Travel
 Local menu: Select (yes)
 Activity code: XX01
 Code. Numeric (incremental)
Library Book  Message. Status:
6202
Status – Available
– On load
– Damaged
– Lost

 Local menu: Select (yes)


 Activity code: XX01
 Code. Numeric (incremental)
Library Book
6203  Message. Type:
Type
– Child
– Student
– Adult

The business solution will allow the selection of a book’s genre from a list, i.e. from the
local menu (lookup table), when a book is added to, or amended in, the Library
Management System database.

Page 7 of 25
1.3 Tables XLMBOOK, XLMMEMBER and XLMLOAN

 XLMBOOK is the master data table for ‘library books’;


 XLMMEMBER is the master data table for ‘members of the library’;
 XLMLOAN is the master loan record data table.

Use the GESATB function (Development > Data and parameters > Tables > Tables) in the
Windows Safe X3 client to create the data tables as follows:

Code/Abbr. Title Key Field Details

XLMBOOK/  General tab:


XLMBOOK
Library Book – Activity code. XX01
and
– Database type. Folder
XLMMEMBER
Library
/ XLMEM – Number of records. 1000
Member
and
Library Book – Table type. Application
XLMLOAN/
Loan – Copy type. No copy
XLMLOAN
 Columns tab:
– Column / Title / Type / Menu / Link tbl / Mand.:
IDBOOK / Book ID / A / / / Yes
TITLE / Book title / DCT
ISBN / ISBN / A
BKGENRE / Genre / M / 6201
BKSTATUS / Status / M / 6202
BKPRICE / Book price/ DCB
DDC / Dewey classification / A
Library Book
DATEPUR / Date purchased / D
XLMBOOK
CREDATTIM / ADATIM
Automatically
UPDDATTIM / ADATIM
Created
AUUID / AUUID
CREUSR / AUS / / AUTILIS
UPDUSR / AUS / / AUTILIS

 Index tab:
– Index code / Index description / Duplicates:
IDBOOK_0 / IDBOOK / No
ISBN_0 / ISBN / No

Library  Columns tab:


Member
– Column / Title / Type / Menu / Link tbl / Mand.:
XLMMEMBER
IDMEMBER / Member ID/ A / / / Yes
Automatically FIRSTNAME / First name / A

Page 8 of 25
Created MIDDLENAME / Middle name / A
LASTNAME / Last name / A
DOB / Date of Birth / D
MEMTYPE / Member type / M / 6203
MEMSTATUS / Active / M / 1
ADDRESS / Address / A / Dim. 5
POSTCODE / Postcode / A

CREDATTIM / ADATIM
UPDDATTIM / ADATIM
AUUID / AUUID
CREUSR / AUS / / AUTILIS
UPDUSR / AUS / AUTILIS

 Index tab:
– Index code / Index description / Duplicates:
IDMEM_0 / IDMEMBER / No

 Columns tab:
– Column / Title / Type / Menu / Link tbl / Mand.:
LOANID / Loan ID / A / / XLMLOAN/ Yes
IDMEMBER / Member ID / A / / XLMEMBER/
Yes
IDBOOK / Book ID / A / / XLMBOOK/ Yes
BORROWDAT / Date borrowed / D
DUEDATE / Date due/ D
RETURNDAT / Date returned / D
Library Book
FINEAMT / Fine amount / DCB
Loan
LOANSTA / M / 1

XLMLOAN CREDATTIM / ADATIM


UPDDATTIM / ADATIM
AUUID / AUUID
CREUSR / AUS / AUTILIS
UPDUSR / AUS / AUTILIS
Automatically
Created
 Index tab:
– Index code / Index description / Duplicates :
LOANID_0 / LOANID / No
IDMEM_1/ IDMEMBER / Yes
IDBOOK_2 / IDBOOK / Yes

Page 9 of 25
2.0 Data Classes

2.1 Data Classes


Create the data classes XLMBOOK, XLMMEMBER and XLMLOAN
Use the GESACLA function (Development > Data and parameters > Classes > Classes)
in the Windows Safe X3 client to create the XLMBOOK, XLMMEMBER and XLMLOAN
data classes, as follows:

Note : When adding properties, use columns selection tools.

Code Title Key Field Details


 General tab:
– Type. Persistent
– Main table.
XLMBOOK (Library Book)
XLMMEMBER (Library Member)
XLMLOAN (Library Book Loan)
– Index.

XLMBOOK Library Book IDBOOK_0 (Library Book)


and IDMEM_0 (Library Member)
XLMMEMBER Library
LOANID_0 (Library Book Loan)
and Member
XLMLOAN Library Book – Activity code. XX01
Loan – Searchable. Select (Yes)
– Scripts (add).
XLMBOOK_CSPE (Library Book)
XLMMEMBER_CSPE (Library Member)
XLMLOAN_CSPE (Library Book Loan)
 Standard methods tab:
– Y/N. Tick C, P, R, U
 Properties tab:
– Property / Type / Menu / Mandatory:
XLMBOOK Library Book
IDBOOK / A / / Yes
TITLE / DCT

Page 10 of 25
ISBN / A
BKGENRE / M / 6201
BKSTATUS / M / 6202
BKPRICE / DCB / / Yes
DDC / A
DATEPUR / D
CREDATTIM / ADATIM
UPDDATTIM / ADATIM
AUUID / AUUID
CREUSR / AUS
UPDUSR / AUS

 General tab:
– Collections (add): XCO_ADD, description
“Address”
Set the number of address lines as 1
(minimum) to 5 (maximum). As members
can be added and deleted tick the fields
Insertion, Deletion, Sort and Addition
 Properties tab:
– Property / Type / Menu / Collec. / Mand.:
IDMEMBER / A / / Yes
FIRSTNAME / A
Library MIDDLENAME / A
XLMMEMBER
Member LASTNAME / A / / / Yes
MEMTYPE / M / 6203
DOB / D
MEMSTATUS / M / 1
ADDRESS / A / / XCO_ADD
POSTCODE / A
CREDATTIM / ADATIM
UPDDATTIM / ADATIM
AUUID / AUUID
CREUSR / AUS
UPDUSR / AUS

 Properties tab:
– Property / Type / Menu / Mandatory:
LOANID / A / / Yes
LOANSTA / M / 1
Library Book IDMEMBER / A / / Yes
XLMLOAN
Loan IDBOOK / A / / Yes
BORROWDAT / D
DUEDATE / D
RETURNDAT / D
FINEAMT / DCB
CREDATTIM / ADATIM

Page 11 of 25
UPDDATTIM / ADATIM
AUUID / AAUID
CREUSR / AUS
UPDUSR / AUS

2.2 Data types


In addition, data types have to be created after data classes.

Code Title Key Field Details

 Type : Reference
 Internal type: Alphanumeric
 Activity code: XX01
XLMBOOK Library Book
 Length: 10
 Type Content : ATYPE7
 Class: XLMBOOK

 Type : Reference
 Internal type: Alphanumeric
 Activity code: XX01
Library
XLMMEM
Member  Length: 10
 Type Content : ATYPE7
 Class: XLMMEMBER

 Type : Reference
 Internal type: Alphanumeric
 Activity code: XX01
Library Book
XLMLOAN
Loan  Length: 10
 Type Content: ATYPE7
 Class: XLMLOAN

These data types have to be added to the ID fields of your tables, data class.

Page 12 of 25
3.0 Data Classes Scripts

3.1 Code to handle Properties

We have three scripts to add on our data classes.

 XLMBOOK_CSPE to:
– Display an error if the ISBN entered by the user is less than 10 characters.
o Use the V6 function “len”
o Use the “ASETERROR” method

 XLMMEMBER_CSPE to:
– Set the status of a library member (MEMSTATUS) to Active (Yes) when adding a
new member to the database;
o Use the “CST_AYES” variable.
– Set the field Date of birth (DOB) to mandatory if the field Member type (MEMTYPE)
is set to Child.
o Use the ASETATTRIBUTE method

 XLMLOAN_CSPE to:
– Automatically set the borrowed date (BORROWDAT) to today’s date;
– Automatically set the loan status (LOANSTA) to yes;
Automatically set the due date of return (DUEDATE) to one week after the borrowed date.

3.2 AXUNIT test


Create an AXUNIT test to create a library book record and test your code.
– Create a new Script QLF_XLMBOOK
– Create a funprog TESTSUITE
– Add a new TEST_CASE
– Add a CHECK_EQUAL to know if your creation succeeds.
– Have a look on the trace.

Page 13 of 25
Create two others AXUNIT test to create a loan and a member.
Note: You can write an Eclipse template here, to use it on different classes.

3.3 Code using events/methods


 XLMBOOK_CSPE to:
– Set the status of a library book (BKSTATUS) to Available when adding a new book
to the database.

 XLMLOAN_CSPE to:
– Set the status of a library book to “On loan” when the book is loaned out;
o Capture an event on XLMLOAN_CSPE
o Instantiate a new book
o Call a XLMBOOK method to update the book
o Create a new method in your XLMBOOK data class
o Use a parameter to read the book
o In this method update your property “BKSTATUS”
o Update your book
– Ensure the loan status of a library book (LOANSTA) is set to Active (Yes) when
adding a new loan record to the database;

Don’t forget to add your method to your method tab in data classes function Source

Where can I find out more?


GitHub Sage-ERP-X3 / dev-doc / Wiki Area: How to guides
Subject: Syracuse Pilot examples
Topics:
– How to set an initial value for a
property
– How to make a property
mandatory or optional from an
update to a different property
– How to change the value of one
property from an update to a
different property

Page 14 of 25
4.0 Representations

4.1 Representations

Create the XLMBOOK, XLMMEMBER and XLMLOAN representation classes


Use the GESASW function (Development > Data and parameters > Classes >
Representations) in the Windows Safe X3 client to create the XLMBOOK, XLMMEMBER
and XLMLOAN representation classes, as follows:

Note : When adding properties, use columns selection tools.

Code Title Key Field Details


 General tab:
– Class code. XLMBOOK
– Instance. XLMBOOK
– Activity code. XX01
– Managed behaviors: As books can be
added and amended tick the fields Create
and Update.
 Organization tab:
– “Section” Block : Code. / Description
BOOK1 / Book header
BOOK2 / Book detail
XLMBOOK Library Book
– “Blocks block" : Code / Section:
HEADER / BOOK1
DETAIL / BOOK2
 Displayed properties tab:
– Property / Block:
XLMBOOK.IDBOOK / HEADER
XLMBOOK.TITLE / HEADER
XLMBOOK.BKGENRE / HEADER
XLMBOOK.BKSTATUS / HEADER
XLMBOOK.ISBN / DETAIL
XLMBOOK.BKPRICE / DETAIL
XLMBOOK.DDC / DETAIL

Page 15 of 25
XLMBOOK.DATPUR / DETAIL
Tick the field Filter for the following:
IDBOOK, TITLE, BKGENRE, BKSTATUS
Tick the fields Query, Detail, Edit,
Enterable, Lookup and Summary for all
properties.

 General tab:
– Class code. XLMMEMBER
– Instance. XLMMEM
– Activity code. XX01
– Search representation. Select (yes)
– Managed behaviors: As members can be
added and deleted tick the fields Create,
Update and Deletion
 Organization tab:
– “Section” Block : Code. MEMBER
– “Blocks” Block : Code / Section:
HEADER / MEMBER
DETAILS / MEMBER
 Displayed properties tab:
– Property / Block:
XLMMEM.IDMEMBER / HEADER
Library
XLMMEMBER XLMMEM.FIRSTNAME / DETAILS
Member
XLMMEM.MIDDLENAME / DETAILS
XLMMEM.LASTNAME / DETAILS
XLMMEM.MEMTYPE / DETAILS
XLMMEM.DOB / DETAILS
XLMMEM.MEMSTATUS / DETAILS
XLMMEM.ADDRESS / DETAILS
XLMMEM.POSTCODE / DETAILS
XLMMEM.CREDATTIM / DETAILS
XLMMEM.UPDDATTIM / DETAILS
XLMMEM.CREUSR / DETAILS
XLMMEM.UPDUSR / DETAILS
XLMMEM.AUUID / DETAILS
Tick the field Query for the following:
IDMEMBER, FIRSTNAME,
MIDDLENAME, LASTNAME,
MEMSTATUS
Tick the fields Details, Edit and Enterable
for the following:
IDMEMBER, FIRSTNAME,
MIDDLENAME, LASTNAME, MEMTYPE,
DOB, MEMSTATUS, ADDRESS,

Page 16 of 25
POSTCODE
Tick the field Lookup for the following:
IDMEMBER, FIRSTNAME, LASTNAME,
MEMSTATUS
Tick the field Summary for the following:
IDMEMBER
 General tab:
– Class code. XLMLOAN
– Instance. XLMLOAN
– Activity code. XX01
– Managed behaviors: As loan records can
be added and amended tick the fields
Create and Update.

 Properties tab – see also Notes below:


– Properties block:
Property / Description / Type / Menu
LIBYESNO / Librarian / M / 1
– .

 Organization tab – see also Notes below:


Library Book
XLMLOAN – “Section” Block ::
Loan
Code. LOAN
– “Blocks” block:
Code / Section:
LOAN / LOAN
DETAILS / LOAN
– Filters block:
Code. LATELOAN
Description. Overdue Loans
Mandatory. Leave clear (No).
Default. Leave clear.
Option condition.
[F:XLMLOAN]DUEDATE < date$ and
[F:XLMLOAN]LOANSTA = 2
 Displayed properties tab:
– Property / Block:
LIBYESNO / LOAN

Page 17 of 25
XLMLOAN.LOANID / LOAN
XLMLOAN.LOANSTA / LOAN
XLMLOAN.IDMEMBER / DETAILS
XLMLOAN.IDBOOK / DETAILS
XLMLOAN.BORROWDAT / DETAILS
XLMLOAN.DUEDATE / DETAILS
XLMLOAN.RETURNDAT / DETAILS
XLMLOAN.FINEAMT / DETAILS
Tick the field Filter P and Entry P for the
following:
IDMEMBER
Tick the field Query for the following:
LOANID, LOANSTA, IDMEMBER,
IDBOOK, BORROWDAT, DUEDATE,
RETURNDAT
Tick the field Detail for the following:
LOANID, LOANSTA, IDMEMBER,
IDBOOK, BORROWDAT, DUEDATE,
RETURNDAT, FINEAMT
Tick the fields Edit and Enterable for the
following:
LIBYESNO, LOANID, LOANSTA,
IDMEMBER, IDBOOK, BORROWDAT,
DUEDATE
Tick the field Lookup for the following:
LOANID, LOANSTA, IDMEMBER,
IDBOOK
Tick the field Summary for the following:
LOANID
Notes – XLMLOAN

Where can I find out more?


GitHub Sage-ERP-X3 / dev-doc / Wiki Area: How to guides
Subject: Syracuse Pilot examples
Topics:
– How to add a URL to launch a web
page
– How to add a filter to the Query
facet

4.2 Adding the representation on the UI


4.2.1 Menu Items

Create a menu Item to open the XLMBOOK, XLMMEMBER and XLMLOAN


representation classes

Page 18 of 25
A menu item to allow records for all three key entities (‘books’, ‘members’ and ‘loans’) to
be added and maintained in the ‘library’ is required.

Menu items are created by selecting the Menu Items link in the Administration Syracuse
page displayed on your ‘navigation page’. The Menu Items link displays a query facet
screen with the list of existing menu items.

The process for making a representation class visible in the client is:

1: Create menu item

2: Create Module

3 : Create sub-module

4 : Add menu Item to sub-modules

5 : Add menu Item to Landing page

Key fields should be set as follows:

Your Menu Item code should match the code used for the master data table you
created in exercise 1. For books this will, therefore, be the code XLMBOOK; for
members, the code XLMMEMBER and for loan records, the code XLMLOAN.

Title/
Code Key Field Details
Description
 Information block:
– Link type. Must be set to Representation.
 Content block:
– Application. X3 ERP
– Endpoint. SEEDCOP folder – Sage ERP
XLMBOOK Library Book
X3 V7 demo folder
and
XLMMEMBER Library – Representation. This field is mandatory
and Member for Representation link types.
XLMLOAN Loan a library
XLMBOOK (Library Book)
book
XLMMEMBER (Library Member)
XLMLOAN (Loan a library book)
– Entity. This field is mandatory for
Representation link types.

Page 19 of 25
XLMBOOK (Library Book)
XLMMEMBER (Library Member)
XLMLOAN (Loan a library book)
– Facet. Query
Where can I find out more?
GitHub Sage-ERP-X3 / dev-doc / Wiki Area: How to guides
Subject: Syracuse Pilot examples
Topics: How to make a class
representation visible in the client

Area: Workbench Reference


Subject: Authoring Functions
Topics: Menu Items

4.2.2 Navigation pages

Add the menu option to the ‘home’ navigation page


Personalisation the navigation page is done in the “navigation pages” activity in the
“Administration Syrause” page.

Two ways to modify it:

_ You can “Edit” the “Home” navigation and create the modules and sub-modules through
hyperlinks. Less user friendly, but allow to write more information (filter on endpoints)
_ You can use “Edit page content” and create on the same window : modules, sub-
modules, menu item links. Most quickly way to do this, add your new elements with “New”
button or Select with “Select”.

4.2.3 Landing page

Add the menu Items to your Landing page

Page 20 of 25
Personalisation the Landing page is done in the “Home” page by clicking on the home
icon

Create a new Landing page for your user.

Use the fist tab and add your menu Items by clicking on the adding icon , then click
on representation, search your menu Item through the search field, and finally select
these.

4.3 Representations Script

 XLMLOAN_RSPE to:
– automatically set the LIBYESNO field to “yes” on creation.
– automatically hide the LOANSTATUS field when the LIBYESNO field is not
checked and display if it is.

Page 21 of 25
5.0 Additional Services

5.1 Logging operations

We want to create a trace when a member is loaning a book or modifying it. This trace will
contain the book’s name, date of return and the user who created it.

5.2 Profiling

We want to know how many times take the calling of update function in the script
XLMLOAN_CSPE.

Page 22 of 25
6.0 Results of the Development Processes

Create and amend a library book and library member / Library member loans a book

1. Your new library book, member and loan Menu Items will be displayed as a link in your
selected vignette.

2. When you have selected your Menu Item link a Query facet screen will display as you
have designed (process step 4):

3. Selecting the Create link in the right panel displays an Edit facet screen as you have
designed (process step 3). In the following example screen the Date borrowed and
Date due fields will be set by the script added to the data class (XLMLOAN_CSPE) but
can be amended by either typing in or selecting a different date:

Page 23 of 25
Page 24 of 25
© Sage 2015
This document is the exclusive property of Sage and/or all of the Sage Group affiliates and is
protected by the Intellectual property Code, copyright laws and international treaties.
Any partial or total reproduction of this document is strictly prohibited.
Anyone not complying with these provisions shall be guilty of copyright infringement and will
be liable to criminal penalties provided by the law.

Page 25 of 25

You might also like