Variable attributes
Variables can be defined with meta-data information.
Syntax
where attributes-list is:
ATTRIBUTES ( attribute [
= "value" ]
[
,...]
)
- attribute is the name of a definition attribute.
- value is the value for the definition attribute, it is optional for boolean attributes.
Basics
To specify metadata information when defining a variable, use the
ATTRIBUTES
clause right after the type:DEFINE myvar INTEGER ATTRIBUTES( ... )
Definition attributes can also be specified for complex types such as records, arrays, dictionaries, as well as for functions.
When defining attributes for complex types, the
ATTRIBUTES
clause must be
specified right after the complex type
keywords:DEFINE uuids DYNAMIC ARRAY ATTRIBUTES(json_name="uuid-list") OF STRING
DEFINE customer RECORD ATTRIBUTES(json_name = "customer-record")
...
END RECORD
JSON serialization attributes
To define JSON serialization options, use variable definition attributes such as
json_null
and
json_name
:DEFINE rec RECORD
cust_id INTEGER ATTRIBUTES(json_null="null"),
cust_name INTEGER ATTRIBUTES(json_name="Customer Name"),
...
orderlist DYNAMIC ARRAY ATTRIBUTES(json_null="undefined") OF RECORD
...
END RECORD,
...
END RECORD
List of supported JSON attributes for variable definitions:
json_null
(values can be"null"
or"undefined"
)json_name
For more details about JSON serialization attributes see BDL names and JSON element names.
XML serialization attributes
Variable attributes are also used when defining variables for XML-based Web
Services:
DEFINE data RECORD ATTRIBUTES(XMLName="Demo"),
val1 INTEGER ATTRIBUTES(XMLName= "Value1"),
val2 STRING ATTRIBUTES(XMLName= "Value2")
attr INTEGER ATTRIBUTES(XMLAttribute,XMLName= "MyAttr")
END RECORD
For more details about XML attributes, see Attributes to customize XML serialization.