Entering content frame

Background documentation Data Types Locate the document in its SAP Library structure

With most Loader commands for loading and unloading data, you can specify the data type that the relevant field values in the data stream have or should have. This specification tells the Loader how to interpret the data in the data stream.

·        When application data is unloaded from a table, the internal database data types are converted to the specified external data types and the corresponding column values are unloaded.

·        When application data is loaded into a table, the specified external data types are converted to internal database data types and the corresponding column values of a table are loaded.

Note

You cannot specify an external data type with the TABLELOAD and TABLEEXTRACT commands.

The external data type and the corresponding internal database data type of the column value in the target table do not have to be identical.

Example

For the values in the columns rno, cno, and hno, the database table reservation requires the internal database data type FIXED.

The DATALOAD command defines the external data type INTEGER for these columns.

DATALOAD TABLE reservation
  rno        01-04 INTEGER
  cno        05-08 INTEGER
  hno        09-12 INTEGER
  type       13-18 CHAR
  arrival    19-28 CHAR
  departure  29-38 CHAR
INSTREAM 'reservation.data' FORMATTED BINARY

The data in the columns rnocno, and hno is converted to the internal database data type FIXED when it is loaded.

Internal Database Data Types

Internal data types are the data types defined for the columns in the database table. For an explanation of all internal database data types, see Data Type (data_type) in the Reference Manual.

External Data Types

External data types are the data types into which the Loader can convert internal database data types when it unloads application data, or they are the data types that the Loader converts into internal database data types when it loads data.

You can specify an external data type as a field specification in the unload or load command for each field value that you want to unload or load (see format_spec).

You cannot specify an external data type in the TABLEEXTRACT and TABLELOAD commands.

If no external data type is specified for a field value, the Loader selects the CHAR data type as the default for this field value. Therefore, if the field value does not have the data type CHAR or the data type CHAR is not desired, you must specify the data type.

The Loader can process the following external data types:

CHAR
(plain text value)

ASCII, UCS2, or UTF8-coded, depending on the server, max. 254 bytes long

INTEGER
(Binary value)

Binary coded (server-specific), 1, 2, or 4 bytes long, sign in bit 0, negative values in two's complement notation

REAL
(Binary value)

Floating point notation with mantissa and exponent, 4 or 8 bytes long, in server-specific notation

DECIMAL
(Binary value)

Packed decimal: one digit per half byte, sign in extreme right half byte, 1 to 10 bytes long, maximum of 18 digits, the position of the decimal point is derived from the table column type

DECIMAL(n)
(Binary value)

n specifies the number of digits on the right of the decimal point

ZONED
(Binary value)

Zoned decimal: /370 zoned data format is permitted, the position of the decimal point is derived from the table column type

ZONED(n)
(Binary value)

n specifies the number of digits on the right of the decimal point

Binary Values

All numeric, external data types (INTEGER, REAL, DECIMAL, ZONED) are interpreted as binary values. These can be converted to any of the internal data types (FIXED, SMALLINT, INTEGER, FLOAT) used by the database.

·        The Loader always interprets data of the data type INTEGER as signed values. The way in which this data is represented in a data stream can be adjusted using the syntax element int_spec.

·        Data of the data type REAL is coded in a host-specific format and cannot be transported between different operating systems and computer platforms without being converted again.

Plain Text Values

Field values with the external data type CHAR are plain text values, that is, these values consist of readable characters.

·        Plain text values can conform to different specifications: ASCII, UCS2, or UTF8 (code specification).

·        You can specify the data formats for plain text values that represent the date, time, or a timestamp (date_spec, time_spec, timestamp_spec).

You can specify these data formats in load and unload commands as a processing specification for the data stream.

Plain text values can be used as inputs for columns of any internal data type used by the database and converted to them. If you want to load plain text values into numerical columns, the values must be able to be interpreted as numbers.

HEX Values

You can use the additional specification HEX to describe an external data type as a hexadecimal value.

This enables you to load or unload all data types in hexadecimal form. Every byte of data in the result is then represented by two hexadecimal numbers. Every value in the data stream then occupies twice as much space as the value of the same data type without the specification as a HEX value.

Example

DATALOAD TABLE room
  hno     01-05
  type    06-11
  free    12-15  INTEGER  
HEX
  price   16-19  INTEGER  
HEX
INSTREAM 'room.data' FORMATTED BINARY

Converting the Data Types

The Loader can convert between numeric data types, if necessary.

You can use the external data type CHAR to read or output any internal database data type.

·        When data is unloaded from a table, the internal database data types are converted to the specified external data types and the corresponding column values are unloaded.

·        When data is loaded into a table, the specified external data type is converted to internal database data types and the corresponding column values of a table are loaded.

 

External Data Type

Internal Database Data Type

Unloading data
from a database instance

FIXED, SMALLINT, INTEGER

INTEGER, DECIMAL, ZONED, REAL

Unloading data
from a database instance

FLOAT

REAL or CHAR[ACTER]

Loading data
to a database instance

INTEGER, DECIMAL, ZONED, REAL

FIXED, FLOAT, SMALLINT, INT[EGER]

Example

DATALOAD TABLE room
  hno     01-05
  type    06-11
  free    12-15  
INTEGER
  price   16-21  
DECIMAL (2)
INSTREAM 'room.data' FORMATTED BINARY

 

Leaving content frame