From an object-oriented perspective, IBM Java Toolbox for I provides a as400datatype interface to describe the specific transformation logic and rules between IBM I data types and Java data types. The implementation classes corresponding to the As400datatype interface can be roughly divided into:
Numerical
Text
Date
Compound type (numbers and text)
Table 1 corresponds to the As400datatype implementation class that is related to numbers.
Table 1. As400datatype-related implementation classes
For IBM i RPG programs, PACKED decimal and zoned decimal are two common numeric types, although they can hold numeric data as they function, but they occupy different storage space. ZONED decimal holds a number in one byte, while packed decimal holds two digits in one byte. As a result, PACKED decimal saves storage space. Based on storage space considerations, IBM I's RPG compiler automatically converts zoned decimal data to packed decimal type. Therefore, it is recommended that you use the packed decimal type to save storage controls and improve compilation efficiency. In addition, the length of the PACKED decimal is defined as an odd length that saves more storage space.
Numeric conversion Classes
As an example, listing 1 describes how to use the As400bin4 conversion class to convert the IBM I format value to Java shaping. It should be emphasized here that all the data for IBM I are represented by byte arrays.
Listing 1. IBM I numeric type conversion Java int type
byte[] data = new BYTE[100];
...
Number Converter
As400bin4 bin4converter = new As400bin4 ();
Integer intobject = (integer) bin4converter.toobject (data,0);
int i = Intobject.intvalue ();