Field Binding

 

Overview

Field binding is used to create a field to allow a value or response to be tied to an RPG program field. With field binding, a new field is created with the name, data type, and length associated with the bound field when the rich display file is compiled. The newly created fields are then able to be used in your RPG program to have a value or response set from the program itself, or to receive a value or response from the application.

If a field is able to be bound, the field binding dialog button will be available in the property:

Clicking this button will open the Field Binding Dialog:

Formatting the Bound Field

There are many different types of formatting that can be applied to a bound field. This allows the data loaded into the field to be displayed in a certain format.

Text - Format used for text. Options here can have the spaces trimmed from leading or trailing spaces. Also allows for text to be right justified and have zero or blanks fill the field.

Number - Used to format numbers. Options here can use Thousands(1000) Separator or show zero balance of the field. And, also allows zero or blank fill for the field. No extra spaces causes an input field to behave as in keyboard shift Y. The number of characters that can be keyed into the field is equal to the length of the field. When no extra spaces option is unchecked, extra characters can be typed for the sign, decimal, and thousands separators. 

     In the example below you can see the differences between all options. The length of data is 10 and 2 decimals.

  • For 1000 Separator the source data '1200000.00' would appear as '1,200,000.00' in the output.

  • Show Zero Balance has source data '00' would appear as '.00' in the output. 

  • For Blank fill the source data '12.34  ' would appear as '12.34' in the output.

  • For Zero fill the source data '12345.60' would appear as '00012345.60' in the output.

  • For No Extra Spaces the source data ' 12345671.89' would appear as '12345671.89' in the output.

 

  • Edit Word - Used to format a numeric field with an editing pattern you specify.

     

     In the example above the source data '000000123' would appear as '****123.00' in the output.

      

  • Edit Mask - Is used to block off certain characters so they cannot be changed in the input field.

     In the example below the edit mask used in conjunction with the edit word property allows the '/' characters to not be removed when backspace or the delete key are used.

                   

  • Currency Symbol - Used to place a character or string representing currency to precede the data. For example '$', '€', or 'Dollars: '.

    

  • Units - The units dropdown can preset the value of the field with a suffix from the following list:

     

Indicator -

Date - This is used to format the value of the field to display as a date.

Time - This format sets the value to display as a time. This can be set for 12 hour or 24 hour display.

Time Stamp - Formats the field with a date and time stamp in the selected format.

Special - These are presets formats designed for different scenarios, such as zip code, social security number, or phone number formats.

Custom - The custom format can be used to specify your own formatting that may not be included in the preset format selections. You can set the selection with custom JavaScript or a custom date/time pattern.

Custom JavaScript Function Example:

Here you can see how to use the custom JavaScript function. This is used to produce custom formatting along with JavaScript code from a separate JavaScript file placed in the userdata/custom/js folder on the IFS.

    

In this example the function determines if the value is greater than 50 it will append '19' to the front of the year, and '20' if not.

function myFunction(num) {   if (num.value > 50)   {   return "19" + String(num.value);   }   else   {   return "20" + String(num.value);   } }

Custom Date/Time Pattern Example:


In the example you can see the pattern M - D - Y / g:i A would return the following format.