Published on System iNetwork (http://systeminetwork.com)
APIs by Example: Number Conversions with _CVTEFN and _LBCPYNV
By tzura
Created Oct 23 2003 - 04:00

In Carsten Flensburg's October 2 APIs by Example, he left the use of the _CVTEFN and _LBCPYNV MI built-in functions to convert numeric fields to a form usable in a record buffer as an "exercise for the reader." In this installment, he offers two sample RPG ILE programs that show you how to use these two functions.

The _CVTEFN (Convert External Form to Numeric Value) function is used to remove display characters, such as currency signs, commas, and decimal points, from a string and convert the resulting number to various numeric formats. The sample program CBX903A shows how to convert the string -12.345.678,912 to packed and binary fields.

The _LBCPYNV (Late-bound Copy Numeric Value) function converts a number to various numeric formats. In the sample program CBX903B, the packed number -12345678.915 is converted into zoned-decimal format.

You can read more about these two MI functions in the "ILE C/C++ for iSeries MI Library Reference" manual at http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c0924180.pdf [1]. The manual is also listed under the "C and C++" topic in the iSeries DocFinder at http://www.iseriesnetwork.com/resources/isndocfinder/c.htm [2].

You can obtain the RPG IV sample program CBX903A and CBX903B at http://www.iseriesnetwork.com/noderesources/code/clubtechcode/ConvertNumbers.zip [3].

The above source code was written by Carsten Flensburg. For questions regarding this tip, contact Carsten at mailto:flensburg@novasol.dk [4].

© 2010 Penton Media, Inc.

Source URL: http://systeminetwork.com/node/61271

Links:
[1] http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c0924180.pdf
[2] http://www.iseriesnetwork.com/resources/isndocfinder/c.htm
[3] http://systeminetwork.com/noderesources/code/clubtechcode/ConvertNumbers.zip
[4] mailto:flensburg@novasol.dk