Field Conversion

 

Introduction

The Field Conversion feature is a powerful solution for cases when a database field is stored in one format, but that value needs to be converted to another format for display purposes.

Any database field might be stored in a format different from its intended display format. In that case, the application is expected to handle that conversion and editing. This feature makes it possible for a developer to write that conversion and editing logic and assign it globally to a particular field in m-Power. Then, m-Power users who make applications over that database will be able to use those fields without adding additional logic to the application and be assured that those conversions and editing will be invoked automatically for them. This greatly simplifies the process of creating applications over fields stored in a format other than their intended display format.

Example Uses

Applicable examples include:

  • A numeric value that represents a date
  • A numeric value stored without decimal positions representing a value that does contain decimal positions
  • A character string storing right-justified values representing a numeric value

Where This Feature is Seen

This feature enables the m-Power administrator to define a Java class that contains custom methods for:

  • Converting a database format to a display format
  • Converting a display (or user-entered) format to a database format
  • Editing a user-entered value

The custom logic for those methods can be written to enable any format swapping and editing needed for any special field conversions. The m-Power client is responsible for creating their own custom logic for their own purposes.

mrc-Supplied Conversion Classes

mrc ships the following classes with m-Power, as examples of implementation:

  • Class com.abc_co.mrcextension.JDEDateConvert converts a JD Edwards date field stored in CYYNNN format to MMDDYY format.
  • Class com.abc_co.mrcextension.FieldConvert150to72 converts a field stored as 15,0 to 7,2.
  • Class com.abc_co.mrcextension.FieldConvert150to82 converts a field stored as 15,0 to 8,2.
  • Class com.abc_co.mrcextension.FieldConvert150to113 converts a field stored as 15,0 to 11,3.

Writing a Custom Conversion Class

The code for Conversion Class JDEDateConvert is supplied here. Follow that example when creating custom Java classes.

How to Define a Conversion Class to a Field

To define a field to convert go to "Manage Data" –> "Manage Tables" and go into "Fields" on the table with the field(s) you want to convert.

Next, edit the field you want converted. The last line of the "Update Dictionary Field" is where you enter the name of the conversion class, listed above.

When you hit "Accept", the field will be converted over in all newly-compiled applications. Now, when m-Power receives the data from the database it will convert it to display in the new format on all applications.

Special Notes

Notes for Fields Defined with a Conversion Class:

  • Formatting of numeric values is still handled with Format Codes.
  • Record selections should be entered with the display format, not the database format.
  • Calculations are treated differently depending on their type. Database Calculations are handled directly in the SQL statement, while Application Calculations are processed after the SQL statement has been executed. Because of this difference, fields assigned with a Conversion Class and used within the calculation expression or the calculation conditions will be handled differently. Database Calculations will use the database format and Application Calculations will use the display format.
  • When a field is defined with a Conversion Class, that logic is applied to all applications using that field in that Data Dictionary. The conversion cannot be un-applied at an application level.

Created: January 31, 2011 | Modified: December 3, 2013