APIs by Example: Number Conversions with _CVTEFN and _LBCPYNV

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.

Download the save file containing the source code.

Read the entire article

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s