The scripting language supports basic data types such as string, numeric and Boolean values. In addition, the existing metadata of the underlying SAP cloud platform for core data types (CDTs) and global data types (GDTs) is made available.
The implementation type of the particular data type is taken into account during the mapping of CDTs and GDTs to the basic types of the scripting language. In the studio, you can explore all SAP data types that are released with the public solution model (PSM) and their implementation type in the Repository Explorer on the Data Types tab. For more information, see Repository Explorer.
The basic data types that are supported by the studio are listed in the following table:
|
Basic Type |
Implementation Type |
Properties |
XSD Data Type |
SAP GDT or SAP CDT, For Example: |
|---|---|---|---|---|
|
Boolean |
|
|
xsd:boolean |
Indicator |
|
Numeric (FLTP) |
INT1 |
1-byte integer (internal). Value range: 0 to 255. The MinimumValue attribute and the MaximumValue attribute define the business contract of the data type. These attributes do not limit the value range technically. |
xsd: unsignedByte |
SMALLNONNEGATIVEINTEGER_DecimalValue |
|
|
INT4 |
4-byte integer (internal). Value range: -2 (MinimumValue ),147,483,648 to +2,147,483,647 (MaximumValue) . |
xsd:int |
|
|
|
DEC |
Decimal number with fixed length (MaximumDigits) and fixed number of fractions (MaximumFractions). |
xsd:decimal |
|
|
|
DF34_DEC |
Decimal floating point numbers of this type are represented internally with 34 decimal places in accordance with the IEEE-754-2008 standard (DF34_DEC). Value range: numbers between 1E6145(1E-34 - 1) and -1E-6143 for the negative range, 0 and +1E-6143 and 1E6145(1 - 1E-34) for the positive range. Values lying between these ranges are in the subnormal range and are rounded. Outside the subnormal range, each 34-digit decimal number can be represented precisely by such a decimal floating point number. |
|
|
|
Numeric Character |
NUMC |
Character string containing the digits 0 to 9 only. Valid content of a numeric text field. The maxLength property specifies the maximum length of the string. |
xsd:token |
AccountingPeriodID FiscalYearID |
|
String |
CHAR, SSTR, and STRG |
Character string containing any alphanumeric characters, including special characters. SAP cloud systems are Unicode systems with the system code page UTF-16. A character has a length of two bytes. The maxLength property specifies the maximum length of the string. |
|
|
|
Binary |
RSTR, RAW |
String of bytes |
|
BinaryObject. In particular: usage of AttachmentFolder dependent object |
|
UUID |
XSDUUID_RAW |
Universally unique identifier |
xsd:token |
UUID |
|
Date |
DATS |
Gregorian date “YYYY-MM-DD” |
xsd:xsd:Date |
Date |
|
GlobalDateTime |
XSDDATETIME_LONG_Z |
Gregorian date and time “2011-12-25T02:30:00Z” |
xsd:DateTime |
GLOBAL_DateTime |
|
Time |
TIMS |
Time “HH:MM:SS” |
xsd:time |
Time |
|
Duration |
XSDDURATION_ISO |
Duration, for example “P12Y11M2DT4H12M40S” |
xsd:duration |
Duration |
|
LanguageCode |
XSDLANGUAGE |
Language code, for example “E” |
xsd:language |
LanguageCode |
For more information, see the data type definitions of the World Wide Web Consortium (W3C ) at http://www.w3.org/TR/xmlschema-2/.
The user interface (UI) runtime of the SAP cloud solution validates the user input according to the data type definition. The following data type properties are checked in particular:
For strings: Maximum length
For numeric values: Minimum and maximum value
For Boolean expressions: Usually represented by a checkbox
For date, time, and duration values: Defined length and content
As a consequence, you do not need to implement validations in your script files to ensure that the user input matches the data type definition. The SAP web service runtime validates the service input according to the data type definition (XSD schema validation).
Internal string variables defined in the scripting language are not restricted in length. “Not restricted” means that the variables are limited by the memory quota of a session, which is defined by the system administrator.
Internal numerical variables defined in the scripting language are of the DF34_DEC implementation type.
|
In the following example, a very long text is used:
|
If variables are typed with data types that belong to the same basic type in the scripting language, they are implicitly converted by the scripting language. For example:
this.ID = this.ShortName;
if ( this.Amount.content > this.IntegerValue) …
If variables are typed with data types that belong to different basic types in the scripting language, they need to be converted by using conversion functions, for example, ToString(), Numeric.ParseFromString(), GlobalDateTime.ConvertToDate()..
If you perform operations on string variables in your script files, you need to ensure that the length of the result strings match the data type definition. For example:
// ShortName is typed with LANGUAGEINDEPENDENT_SHORT_Name -> length = 10// LongName is typed with LANGUAGEINDEPENDENT_LONG_Name -> length = 40this.ShortName = this.LongName.Substring(0, 10);
|
The program terminates when saving if the length of the LongName field is greater than 10 characters and no check exists. |
If the content of a variable is outside the range that is specified by the data type definition, the following can occur as a consequence:
Program termination, for example, an overflow error
A system message
An implicit conversion, for example, a cutoff
|
Variables of unrestricted length, for example, variables of the LANGUAGEINDEPENDENT_Text data type, are truncated at a length of 255 characters as soon as they are saved to the database. For texts that are longer than 255 characters, use the TextCollection dependent object. |
For variables that are typed with numerical data types, rounding is performed according to the definition of the target data type. While the scripting language uses decfloat34 internally, the values are rounded according to the definition of the data type as soon as the value is assigned to a business object element.
|
Note: The Quantity.content data type is specified as a decimal value with 31 digits and 14 fractions.
|
For identifier data types, additional properties are specified in the GDT definition:
Upper case conversion
Alpha conversion
Alpha conversion fills purely numeric user input like “4711” with leading zeros from the left side to allow better sorting in character fields. For example, if alpha conversion is not used, an alphabetic sorting would lead to sorting results such as: “1”, “10”, “100”, “1000”, “2”, “20”, “200”, and so on.
The UI runtime performs upper case conversion and alpha conversion automatically. The scripting language, however, does not perform these types of conversion automatically. Therefore you need to ensure this in your script files.
|
ID data type (supporting upper case conversion and alpha conversion)
The result is —1 because the content of the ID is not automatically converted to upper case. To convert to upper case, use the ToUpperCase built-in function, for example:
|
Code data types can be mapped to the string basic type or the numeric character basic type. The behavior of a variable typed with a code data type, for example, PriorityCode, ApprovalStatusCode and Amount.currencyCode, is as follows:
The variable can contain alphanumeric characters or numeric characters. The value range is then defined by fixed or configurable code lists.
A variable can be assigned, compared, and so on, to a string data type (“=”, “==”, “+”) if the variable is typed with a code data type mapped to the string basic type . If the code data type, however, is mapped to the numeric character basic type, you need to use the ToString built-in function in order to assign or compare the variable to a string data type.
The variable cannot be assigned, compared, and so on, to other code data types (“=”, “==”, “+”)
The UI runtime performs a content check of the code list. The scripting language, however, does not perform this check automatically. Therefore you need to ensure this in your script files.
|
|