Tuesday, January 15, 2008

Checking for user changed screen data:

In the world of green-screen programming, one basic function a program has is dealing with information that the user enters on the screen, including changes to data.

On a simple screen, processing user-entered changes can be straightforward--editing, validating, and then processing. On more sophisticated screens, it is not as straightforward.

Some times we have many fields in the screen and we need to validate all the fields before processing. So why should we check all the entries in the screen, If the data hasn't changed from the last time the user pressed Enter (or another function key), We really don't want to re-validate the data or rebuild the page. That would be redundant.

One way to check for changes in screen data is to use the CHANGE keyword for display file DDS. The syntax is CHANGE(nn), where nn is an indicator. This can be a record-level keyword to apply to all input-capable fields in the format, or it can be a field-level keyword. If the user types into a field that is affected by this keyword, then indicator nn is set on. All your program needs to do is check that indicator to see if the data in the field has changed and do the processing.

This helps to avoid the redundant checks performed for all the fields irrespective of its change.

No comments: