Class ROUTINE
Syntax
![]()
Command
Mandatory parameter Optional parameter Mandatory keyword Optional keyword |
{PRIVATE|PUBLIC} ROUTINE <Class>.<Routine> [(<Parameterlist>)][ : <Resulttype>]
[CONST
<Definitions>]
[VAR
<Definitions>]
[BOOLEANS
<Definitions>]
BEGIN_ROUTINE
<Code lines>
END_ROUTINE
Description
Defines a class routine which can be defined in forms, reports, global performable routines objects as part of a locally defined class and in global class definitions.
Diagram
Returned value type
Depends on the <result type> definition
Parameters
Parameter | Description | |
PRIVATE | PUBLIC | The access modifier of the class routine. Private class routines can only be accessed from inside a public class routine of the same class. Public class routines defined in a global class can be accessed from any routine in a form, report or global performable routine. Public class routines from a locally defined class can be accessed from any routine in the object where the class is defined. While an access modifier keyword is not mandatory, the default is private, it is advised to always add it to create a better overview. |
|
<Class>.<Routine> | Name of the class routine. | |
<Parameterlist> | List of declarations. Unless for constant declarations, the parameters (fields) that are specified in this list can be invoked directly through a Class Routine-Call. To each specified parameter a type and a length have to be assigned. If multiple variables have the same type and length, you may declare these variables together instantly. You may also specify the options VAR or CONST, which are comparable with these specifications for definitions inside the routine. The syntax for specifying the declarations is the following: [VAR | CONST] <Field specification> [:] <Type> <Length> [OPTIONAL] |
|
VAR | Declares that the specified fields are variables to be called by reference. When using this option, the following rules apply:
|
|
CONST | Declares that the specified fields are constants. When using this option, fields are treated as readonly and therefore cannot be changed through the calling routine. | |
<No type definition> | When no type definition is given, the parameter will be available as variable inside the procedure, but changes to its value will only effect the local variable. | |
<Field specification> | Specification of one or more field names. When declaring multiple fields at once, you have to use the comma (,) as a separator. This way, these fields will instantly be defined with the same characteristics. It is possible to use DCT in variable declarations in the routine header, e.g.:
routine Local_Class.new_travelnr (lc-travelnr dct travelnr)
|
|
<Type> | The type of the variable(s), which may be ALPHA, NUMERIC, BOOLEAN, STRING, INTEGER, SIGNED, FINANCIAL, PRINTER (for text reports) or PRINTERGRAPHICAL (for graphical reports). | |
<Length> | The maximal length of the specified variable(s). This parameter only has to be specified if the type is ALPHA or NUMERIC. The number of decimals are supplied after a dot. | |
OPTIONAL |
When specified this parameter can be omitted in the call to the routine. This can only be used for the last (consecutive) parameters in the parameter list. |
|
<Resulttype> | Type that is returned after the routine has ended. Also the DCT can be used.
routine Local_Class.new_travelnr (sa-travelnr alpha 19) : dct travelnr
routine Local_Class.new_travelnr (sa-travelnr dct travelnr) : dct travelnr
|
|
CONST | Declares that the next <Definitions> defines constants that can only be used locally inside the routine. | |
BOOLEANS | Declares that the next <Definitions> defines a boolean function that can only be used locally inside the routine. | |
VAR | Declares that the next <Definitions> defines variables that can only be used locally inside the routine. | |
<Definitions> | Definitions for constants or variables that are used in the program. To make it possible to call multiple variables at once locally, variables can be defined within a structure. | |
<Code lines> | Code lines that are executed within the routine. Only class members of the same class, global items and system items are accessible inside a class routine. Other locally defined items such as variables, routines and screen objects are outside of the scope of a class routine. |
Remarks
Parameters for the routine are defined in the <Parameter list>.
Optionally, you may specify a <Result type>. The value of the variable result will then be returned as return value.
After the routine definition header the definitions of the constants (CONST part) are specified, followed by the variable definitions (VAR part).
The instructions that must be executed when the routine is called, are specified between the keywords BEGIN_ROUTINE and END_ROUTINE.
Inside class routines, it is only possible to access other class members (both class variables and class routines) of the same class, global items (global variables and global routines) and system items. Variables, routines and screen items defined in a form or report can not be accessed inside a class routine, they are outside the scope of a class routine.
Example
begin_routine
this.carColour := colour_code
this.carClrDate := today.yymmdd
this.emailUpdates()
end_routine
Relevant pages: