Classes standard methods
Once classes are defined, the corresponding methods are available to be managed. Some methods are generic, some are attached to the persistent classes, some are linked to their properties, and others to child classes collection. This document describes these methods.
Calling Methods of a Class | Standard Methods of a Persistent Class | Methods Associated with a Property |
Other Methods | Standard Methods Associated with Child Class Collections |
The methods described in the class dictionary will be called by the following syntax:
RETURN_VALUE=Fmet MYINSTANCE.MYMETHOD(argument lists)
This
keyword gives you access to the current instance. Any property of the current instance of the class can thus be accessed by using the syntax:this.PROPERTY
The access to a child class is possible with the following syntax:this.CHILD_INSTANCE.PROPERTY
If the class is a child of a parent class, the APARENT
property provides access to the parent class. For example, if we are on an action located at the detail level of a sales order, this.PROP1
refers to a property of the line, while this.APARENT.PROP2
refers to a property present on the header.
In another example, suppose that in the SORDER class, you declare a method VALIDATE that performs several actions and sets in the instance MYORDER the property VALIDATED to 1. The update of this property can be performed by the following line written in the code of the method:
this.VALIDATED=1
Callmet
instruction also exists for some automatic methods that do not return values.If the class is persistent, automatic methods for CRUD operations can be generated if the corresponding check boxes are set in the class dictionary of the Standard method section. They are called:
AINSERT
, AREAD
, AUPDATE
, and ADELETE
AINSERT
, AUPDATE
, and ADELETE
have no parameters. The instance in which they operate defines the context. AREAD
has the N segments of the main key to be read in the main table.
A development partner can manually call these methods. However, when a standard CRUD operation is initiated from an activity, the supervisor layers automate the corresponding calls.
A class can integrate child classes linked to other tables that must be updated when the main class is updated. This is described in the mapping section of the data class dictionary. For each table, the method of the main class can either call the corresponding methods of the child classes or get the data by reading the data table.
This is defined by the class management check box defined in the Linked Table grid:
Even if the CRUD code is generated, events exist in this code to allow a development partner to complete or change the standard behavior managed by the supervisor layer.
They are defined in Developer Guide Classes Events
Standard methods also exist for the properties within a class. They are called rules and are not directly called by the development partner, but implicitly.
For example, if a line such as MYINSTANCE.PROP1 = MYINSTANCE.PROP2
is executed:
GET
rule is called on PROP2.CONTROL
rule is called on PROP1.PROPAGATE
rule is called on PROP1.In these methods, this.PROPERTY
gives access to the current property, and AINDICE
gives access to the index if the property is a collection or an “array” in the version 6 vocabulary.
In the CONTROL rule, when a creation or update operation is in progress, you know the initial value of the snapshot property that also gives access to the previous value (the new value is already assigned and will remain if nothing is done). For example, a control fails on a numeric value and the initial value can be reassigned by:this.PROPERTY=this.snapshot.PROPERTY
For any declared class, a method called C_CLASS_NAME exists. It is the method invoked after every instantiation of the class or a "constructor" method.
In addition to all standard methods, any other method can be added in the dictionary, and such a method can contain parameters. For example, an INVOICE class has a POSTING method with a date parameter. Calling this method would be created by the line:RETURN_CODE=Fmet MYINVOICE.POSTING(date$)
When child class collections exist in a class, standard methods allow you to manage these collections.
A collection is managed in memory with two types of indexes:
PROP
from the N
th line of a collection COLL
in the current instance is done by this.COLL(N).PROP
.this.COLL(N).AORDER
.When an instance is created for a class that has child class in collections, only the main instance is created, and the child instances will be created by using the corresponding method. There is one notable exception which is the collections typed (1,1). In this case, the child instance is automatically created along with the main instance.
Note that a line in a collection (0,N) or (1,N) has a status given by the technical property this.COLL(N).ASTALIN
. If this property has a value equal to [V]CST_ANEWDEL
or to [V]CST_ADEL
, the line is no longer present in the grid (its deletion has been requested). When the update of the main instance is done, these lines will be deleted from the database. The next time the AREAD method is performed, the collection lines will again contain only the existing lines.
The methods that manage the collections are the following:
This method inserts a line in a collection at the position given by LINE_POS
.
LINE_POS
contains one of the following values:
[V]CST_ALASTPOS
: insertion at end of the collection.[V]CST_AFIRSTPOS
: insertion at the beginning of the collection.I
between 1 and the number of lines performs an insertion at the position I
. The lines located between the position I
and the end of the collection are shifted to the next position.It returns the index of the inserted line, and [V]CST_ANOTDEFINED
if the insertion was not possible.
This method deletes a line in a collection at the position given by LINE_POS
:
[V]CST_ALASTPOS
: deletes the last line of the collection.[V]CST_AFIRSTPOS
: deletes the first line of the collection.It returns [V]CST_AOK
if the deletion is successful and [V]CST_ANOTDEFINED
if it fails.
This method recovers the current index corresponding to a given position in the collection.
It returns the index of the line, and [V]CST_ANOTDEFINED
if the line does not exist.