XLR3Script reference
Introduction
XLR3Script is a scripting language whose objective is to provide a fast, flexible and easy way to manipulate the data used by the XLR3 Data Injector. It is voluntarily simple and proposes only the functions that are necessary to achieve its objectives.
Data Types
Data types are used to describe data. They give information over the way data is stored in memory (mainly its size) and the possible values it may comprise.
With XLR3Script, the data types are not explicit, they are always determined by the context. So the data types listed below do not constitute XLR3Script keywords and may not be used directly in the language as they are used only internally.
List of data types
| Type | Description |
| Integer | The integer type describes signed integer values on 32 bits ranging from -2^16 to 2^16 - 1. |
| String | The string type describes a string of characters of any size. |
| Record | A record is an object that contains data to be inputed in SAP whose structure is determined by an associated record type. A record is made up of screens objects. |
| Screen | A screen is an object element that contains fields data dynamically generated. |
| Field | A field is an elementary unit of data that is used to fill in a corresponding field in SAP screens. |
| Excel Sheet | Corresponds to an Excel sheet. An Excel sheet is basically a list of Excel rows. |
| Excel Row | Corresponds to an entire row of an Excel sheet. A row consists of an array of Excel columns. |
| Excel Column | An Excel column belongs to an Excel row and their intersection identifies a single cell. An Excel column corresponds to an Excel cell. |
| Undefined | This special type is used internally for intermediate stages of operations. No operation is possible on data of such type but it could arise in error messages. |
Data types conversions
Some conversions between data types may occur within mathematical and logical expressions automatically depending on the context of use. On the other hand it is not possible to explicitely ask for a conversion of data type (casting) as all authorized conversions are handled automatically.
The possible conversions are:
| From type | To type | Behaviour |
| Integer | String | Integer is converted to a string representing the same number. |
| String | Integer | String is converted to an integer interpreting only digits and '-' sign. |
| ExcelColumn | String | The resulting string is the content of the ExcelColumn object (corresponds to a cell content of the excel sheet). |
Variables
Variables are dynamic containers for data. They are characterized by a name, a type and a value. As the type information is managed by XLR3Script, you only need to deal with the name of the variables and their values.
Variables names
Only alphanumeric characters and '_' are valid characters for variables names. However, a digit may not be used as first character of a variable name.
Variables values
Variables are not declared in XLR3Script. They are created automatically the first time they are assigned a value and their type is set to the type of that first assignment value.
As variables are not declared and consequently not initalized neither during the declaration, a variable may not be used before it is first assigned a value.
The assignment of a value to a variable is either explicit or implicit. The explicit assignment consists in assigning a value to the variable using the '=' operator.
The implicit assignment consists in assigning a value to a variable as a result of an operation whose main purpose was not to assign a value to the vraiable. In this case, the value assignment is only a consequence of the operation.
Examples of variables assignments and data types conversions
x = 10 Creates the variable x with integer type and assigns the integer value 10 to it.
y = 'hello' Creates the variable y with string type and assigns the string 'hello' to it.
z = '15' Creates the variable z with string type and assigns the string '15' to it.
LOOP AT RECORDS INTO Record Creates the variable Record with type Record and assigns the record values contained in the table RECORDS to it. This is an example of implicit assignment.
Scope
The scope, which defines where variables exist and are accessible, is global for all variables no matter where they are created.
Arrays
Arrays are currently only partially supported. They may be read and written but it is not possible to create new arrays or extend existing ones. Only the internal arrays (like the array of records, the arrays of screens of each record, ...) may be used.
Elements of an array may be selected thanks to the special operator [] which mentions the zero based index of the element to be selected or thanks to LOOP statements.
Trying to access an element of an array that does not exist produces a run time error. Valid index for an array range from 0 to the size of the array - 1.
Mathematical expressions
Operators
The following operators may be used in mathematical expressions:>
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Division |
| ^ | Power |
| % | Modulo |
All these operators apply to integer values and the necessary types conversions occur if strings are used with these operators. An exception exists for the addition operator (+) which makes no conversion if both operands are strings and concatenate both strings instead.
Priorities
Mathematical expressions are normally treated from left to right and operators are applied in that order. However, priorities are assigned to operators and operators with higher priorities are treated before preceeding operators with lower priority.
The operators ^ and % have the higher priority followed by * and / and finally by + and - which have the lowest priority.
Parenthesis may also be used to give absolute precedence to an expression not matter the operators it contains.
Logical expressions
Operators
Currently, there exists only 2 logical operators which can be combined: AND and OR.
Priorities
The logical expressions are evaluated like mathematical expressions from left to right. The AND operator has priority over the OR operator but parenthesis may be used to influence these priorities.
Functions
Functions are blocks of code that receive parameters in input and produce in output a result in the form of a value of a predetermined type.
Currently, only predefined functions may be used in XLR3Script. Developers have no possibility to create their own functions.
You may consult the list of predefined functions per category in the functions list.
Predefined objects and methods
The data types Integer and String are elementary data types. All other data type are special data types are sepcial data types since they describe objects.
XLR3Script is not object oriented since it does not support the key features of object oriented programming such as encapsulation, polymorphism or inheritence. However, XLR3Script presents records, screens and fields, ... as objects with attributes and methods.
Developers don't have the possibility to create their own object types (classes). They may only use the existing data types and access the existing attributes and methods of the existing object types.
To access the attributes or methods of an object, the '.' operator must be used between the object and the attribute or method to specify that the attribute or method belongs to the object left-pointed by the '.' operator.
You may consult the list of predefined object types and along with their attributes and methods in the objects list.
Conditional statements
The IF ... ELSE IF ... ELSE ... ENDIF construction may be used in XLR3Script to execute instructions conditionally.
The construction look like this:
IF logical-expression
Instructions
ELSE IF logical-expression
Instructions
ELSE
Instructions
ENDIF
Loops
Only one type of loop is supported: the loop on an array of values. As arrays may not be defined by developers, they necessarily apply to internal arrays.
The LOOP AT array INTO variable instruction loops through the entries of array sequencially and assigns at each pass the corresponding value of the array to the variable specified.
The array may be either RECORDS which is a preexisting variable indicating the array of all records currently existing or an array of values obtained from an object such as the rows of an excel sheet or the screens of a record.
|