# KB Article 15469 2017/11/28

Close
X Contact Tech Support Email Tech Support
(250) 655-1766
[7:30 - 5:00 PST] Tech Support
Tech Support Home
Knowledge Base Search
Recent KB Articles
Product FAQs
Code Samples
Documentation
Tech Blog
System Requirements
Installation Instructions
Support Testimonials
Create a Ticket
Request a Free Demo
Suggest a New Feature
Submit Feedback
Other Services
Software Training
Professional Services

# What are the maximum lengths and values of work field data types in WebSmart?

Product: WebSmart ILE Type: Frequently Asked Question

This information was compiled in Websmart 11.3, on an IBM i series OS V7R1.

#### Basic Data Types

Alpha ("A")

• Equivalent to RPGLE's Fixed Length Character type.
• An alpha field can be of length 1 to 65535.
• Length in Bytes: 1B per character.

Variable Len ("V")

• Equivalent to RPGLE's Variable Length Character type.
• A Variable Length field can be of length 1 to 65535.
• When defining the field, we set the maximum length of string the field will store.
• Length in Bytes: 1B per character (using maximum length) plus 2B for the current string length.

UCS-2 ("C")

• Equivalent to RPGLE's Fixed Length Graphic field type, encoded using UCS-2 (CCSID 13488).
• Can be of length 1 to 16383.
• Length in Bytes: 2B per character.

Numeric ("N"), Signed ("S")

• Equivalent to RPGLE's Packed Decimal data type.
• Can be of length 1 to 63.
• If using decimals, the total length of the number is L + R <= length, where L is the number of digits to the left of the decimal and R is the number of digits to the right of the decimal.
• Maximum value = 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999.
• Minimum value = -999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999 999.
• If all digits are decimal, the number of least possible magnitude is .000000000000000000000000000000000000000000000000000000000000001.
• Length in Bytes: depends on the total length. 1 or 2-digits = 1B, 3 or 4-digits = 2B, ... , 62 or 63-digits = 32B.

Binary ("B")

• Can be of length 1 to 9.
• As with Numerics, with decimals L + R <= length.
• Maximum value = 999 999 999. Minimum value = -999 999 999.
• Length in Bytes: 1-4 digits = 2B, 5-9 digits = 4B.

Integer ("I")

• Can be of lengths 3, 5, 10, or 20.
• Cannot have decimals.
• Integer 3
• Maximum value 127.
• Minimum value -128.
• Length in Bytes: 1B.
• Integer 5
• Maximum value 32767.
• Minimum value -32768.
• Length in Bytes: 2B.
• Integer 10
• Maximum value 2 147 483 647.
• Minimum value -2 147 483 648.
• Length in Bytes: 4B.
• Integer 20
• Maximum value 9 223 372 036 854 775 807.
• Minimum value -9 223 372 036 854 775 808.
• Length in Bytes: 8B.

Float ("F")

• Can be of lengths 4 or 8.
• No need to specify decimals.
• Floats have a default precision based on length.
• Maximum and minimum magnitudes are listed.
• Floats can be both positive and negative values with these magnitudes.
• Float 4
• Precision 7 decimal places.
• Maximum magnitude = 3.40282356 × 1038.
• Minimum magnitude = 1.17549436 × 10-38.
• Length in Bytes: 4B.
• Float 8
• Precision 15 decimal places.
• Maximum magnitude = 1.7976931348623158 × 10308.
• Minimum magnitude = 2.2250738585072014 × 10-308.
• When defining values in WebSmart, you cannot define numbers longer than 63 digits, but if you multiply or divide 2 values of this length, a Float of length 8 can hold the result, up to the specified magnitudes.
• eg, 999999999999999999999999999999999999999999999999999999999999999 * 999999999999999999999999999999999999999999999999999999999999999 = 1.000000000000001 x 10126.
• Length in Bytes: 8B.

#### Data Structures

Data structures can contain elements of any of the basic data types listed above.

Data structures have a maximum size of 65535 bytes. This is equivalent to an Alpha of maximum length.

If you created a data structure which contained an Alpha of maximum length, then that data structure could not contain any other elements.

The above information on the basic data types includes the Byte lengths of each data type to aid in calculating the size of your data structure.

#### Arrays

Arrays can be made up of elements of any of the basic data types listed above.

If the array is created using crtstructarr() instead of crtarr(), the elements of the array can be a data structure. See KB#10166 for details.

Arrays have a maximum number of elements of 32767.

The total size in bytes of the array must be less than 16 773 104 (16MB), therefore:

• You can create an array of 32767 elements with a maximum size of 511 bytes.
• You can create an array of 255 elements with a maximum size of 65535 bytes.

#### A Note on functions

Functions have a local maximum storage allocation limit of 16 773 104 bytes (16MB), which must include any local fields.

This must be taken into account when calculating your storage usage. Creating an array of the sizes listed above may not be possible if the function already includes other locally defined fields or calls other functions.

Parameter fields of a function are not added to that function's allocation pool. They are added to the calling function's allocation pool.

For example:

``````func foo()
{
crtarr(mylist, 511, "A", 0, 32767, "");
bar(5);
}
func bar(num1)
{
crtfld(num1, 1, "N", 0, "");
crtfld(string1, 65535, "A", 0, "");
}``````

In the above, the parameter field num1 must be counted in the allocation for the function foo(). The field string1 is counted in the allocation for bar(). The program will compile as storage does not exceed 16MB of either function.

``````func foo()
{
crtarr(mylist, 511, "A", 0, 32767, "");
bar("foobar");
}
func bar(string1)
{
crtfld(num1, 1, "N", 0, "");
crtfld(string1, 65535, "A", 0, "");
}``````

In this example, we now add the storage for string1 to the allocation for the function foo(). The field num1 is added to the allocation for the function bar(). The program fails to compile because the total storage for the function foo() is greater than 16MB.

``````func foo()
{
bar("foobar");
}
func bar(string1)
{
crtfld(num1, 1, "N", 0, "");
crtfld(string1, 65535, "A", 0, "");
crtarr(mylist, 511, "A", 0, 32767, "");
}``````

In this example, we have moved the crtarr() call to the function bar(). Now the function foo() allocates storage for string1, while bar() allocates storage for mylist and num1. The program compiles as neither function's storage allocation exceeds 16MB.

If fields are defined in Main(), then they are defined globally and are not subject to the per-function storage limit.