Data types and APIs

APIs support character data and binary data.

Character data

In the API parameter tables, CHAR(*) represents the character data that has:

  • A type that is not known, such as character or binary
  • A length that might not be known or is based on another value (for example, a length you specify)

Binary data

In the API parameter tables, BINARY(2), BINARY(4), and BINARY(8) represent numeric data. These parameters must be signed, 2-, 4-, or 8-byte numeric values with a precision of 15 (halfword), 31 (fullword), or 43 bits and 1 high-order bit for the sign. Numeric parameters that must be unsigned numeric values are explicitly defined as BINARY(x) UNSIGNED.

When you develop applications that use binary values, be aware that some high-level languages allow the definition of binary variables by using precision and not length. For example, an RPG definition of binary length 4 specifies a precision of 4 digits, which can be stored in a 2-byte binary field. For API BINARY fields, RPG developers should use one of the following:
  • Positional notation (1 2B 0) for 2-byte binary
  • Positional notation (1 4B 0) for 4-byte binary
  • A length of 1 to 4 for 2-byte binary (4B 0)
  • A length of 5 to 9 in order to allocate a 4-byte binary field (9B 0)
  • A length of 5 for 2-byte signed integer (5i 0)
  • A length of 5 for 2-byte unsigned integer (5u 0)
  • A length of 10 to allocate a 4-byte signed integer field (10i 0)
  • A length of 10 to allocate a 4-byte unsigned integer field (10u 0)
  • A length of 20 to allocate an 8-byte signed integer field (20i 0)
  • A length of 20 to allocate an 8-byte unsigned integer field (20u 0)