ILE C/C++ Programmer's Guide


Using Externally Described Packed Decimal Data in a Program

The ILE C/C++ compiler and library supports packed decimal data.

The d option of the #pragma mapinc directive causes the compiler to generate packed decimal variables for any packed decimal fields defined in the DDS file. If you use the p option of the #pragma mapinc directive or the PKDDECFLD parameter of the GENCSRC command, character arrays are generated to store the packed decimal values.

C++ language onlyC++ users must use the GENCSRC utility to create type definitions from an external file.

C language onlyC users can use either the GENCSRC utility or the #pragma mapinc directive to create type definitions from an external file.

Note:
For more information on the differences between the GENCSRC utility and the #pragma mapinc directive, see Appendix A, The GENCSRC Utility and the #pragma mapinc Directive.

These character arrays then need to be converted to an ILE C/C++ numeric data type to be used in the ILE C/C++ program. If neither the d or p option is specified, the d option is the default. See Chapter 26, Using Packed Decimal Data in a C Program or Chapter 27, Using Packed Decimal Data in a C++ Program for examples in using packed decimal data types.

Note:
If you have a DDS file with packed decimal fields defined in your program, your source code must:

Use either the #pragma mapinc d option or the GENCSRC PKDDECFLD parameter in your ILE C/C++ source code.

Note:
The ILE C/C++ compiler and library do not support zoned decimal data. If there are zoned fields, #pragma mapinc and GENCSRC convert them into *CHAR type.

To convert packed decimal data that is stored in character arrays to integer or floating point (double) and vice versa, the functions QXXDTOP(), QXXITOP(), QXXPTOD(), QXXPTOI() can be used.

To convert zoned decimal data that is stored in character arrays to integer or floating point (double) and vice versa, the functions QXXDTOZ(), QXXITOZ(), QXXZTOD,() and QXXZTOI() can be used.

The MI cpynv() function can also be used to convert packed or zoned decimal data to an ILE C/C++ numeric data type. It can be used to convert an ILE C/C++ numeric data type to packed or zoned decimal data.

The conversion functions are included with the ILE C/C++ compiler so that EPM C code that uses these functions can be maintained.

If you are doing database I/O operations, you can use a logical file with integer or floating point fields to redefine packed and zoned fields in your physical file. When you perform an input, or output operation through the logical file, the iSeries 400 system converts the data for you automatically.


[ Top of Page | Previous Page | Next Page | Table of Contents ]