|Configuring Tools and Settings||Customizing Macros|
This chapter describes year types and how to customize them as well as how to set up the rules for automatic assignation of year types. Year type and assignment rules are essential for finding, fixing and verifying dates. Data items hold values which can represent a date but do not necessarily have to.
A year type defines how data items of that year type are to be handled. The year type defines, among other things, the macros to use to expand and contract data items with that year type. This is used when fixing data items and not when verifying.
SmartFind Plus provides a set of year types and macros for the common cases. It is possible that the application has some dates that do not fit the supplied year types and are not handled by the supplied macros. If you find you need additional year types and macros, you can customize the supplied ones or write your own.
If you want to customize any year types or macros, we recommend that you do so as soon as possible after starting work on a project, as your customization will impact any existing entries in the worksheet. For example, customizing a macro might invalidate a manual fix that you have made to statement.
How a data item should be expanded depends on a variety of things including: the data item's logical date format (such as yymmdd); its physical format (such as PIC 99); and the 100-year window from which to derive its century (such as 1960-2059).
Consequently, you must specify these things for each data item before SmartFix can expand it. You do this by assigning a year type to each date candidate. The year type can define, amongst other things, the macros to use to expand the two-digit years into four-digit years.
When assessing the dates in the application and deciding which year type to assign to each date candidate, you need to consider:
You need a year type that corresponds to the logical data format of the date held in the data item. For example, the year type for expanding ddmmyy is different than that for expanding yymmdd.
You need different year types for different physical representations because the results from arithmetic and comparisons differ. For example, if a macro dealt with numeric items of any format, a move to a numeric expanded item automatically converts between formats, but the move might fail if it is to an alphanumeric field that contains a space.
You can ignore edited data items, as these are for display only and so do not cause a logic error at the century boundary.
You need different year types for those dates. In some cases, the different year types refer to different macros, and in other cases the different year types pass different parameters to the same macros.
Although you can assign only one year type to a data item in the worksheet, you can override the year type for an individual statement, or turn it off altogether.
You can assign these data items a year type of Manual, and then SmartFix does not attempt to expand or map them in any way.
|Data item type:
||Action required for fixing
|no date format: never holds a date value||nothing need be done, do not be include in the worksheet|
|fixed format: only ever holds a date in one format||identify that format then SmartFind Plus can automatically identify code that fixes statements|
|variable format: sometimes holds one format sometimes another||you must always examine each statement to work out which format and fix code is appropriate.|
For detailed implications of different formats and data definitions, see the chapter Year 2000 Problems and Solutions
When fixing, additional considerations apply. See the Fixing Date Problems chapter.
Note: If a data item is moved to another data item, then the date format will move with it. This is one way to identify data items that hold dates and need adding to the worksheet.
Use Administration, and then Edit year types to see details of a selected year type, to customize it, and to change the parameters passed to the macros, such as the 100-year window. Figure 6-1 shows the window for editing the year type called YYMM9:
Figure 6-1: Edit Year Type YM9
Each year type defines, among other things:
For full details on how to customize year types, click Help in the top right corner and click the field on which you want help.
Year type definitions are held together with the assignment rules in a year type file. You can store your customized year types in a year type file that applies to the current project, all your projects or shared across a network. See the section Year Type Files for details.
Use Administration, and then Edit assignment rules to define the rules that map a data item attribute to a year type. Figure 6-2 shows the default year type rules configuration.
Figure 6-2: Assign Year Type Rule Configuration
Among other things, the default rules stipulate that:
Note: You can automatically assign year types to data items when you add them to the worksheet. To do this, check Assign year type when adding data items to worksheet. You can also weight each rule to indicate those that are more likely to be accurate, with 100 being the most likely.
The assignment rules are held together with the year type definitions in a year type file. You can store your configured assignment rules in a year type file that applies to the current project, or one that applies generally to all your projects. See the section Year Type Files for details.
For details on how to configure the assignment rules, click Help in the top right corner and click the field on which you want help.
Year type definitions and assignment rules are held together in a year type file, which has the extension .fxt. There is one year type file for each Micro Focus macro library, one for each user-defined library and one for each project.
If you add or change any of the supplied year types, you can store the updated year type file as one of the follows:
SmartFind Plus looks for the year type file in the project directory first, and if the file is not there, SmartFind Plus uses the year type file from the library specified in the Fix Options tab of Options.
SmartFix supplies two macro libraries: one for fixing ANSI '85 COBOL and one for ANSI '74 COBOL. Each library has its own subdirectory structure under the revolve\fixlib directory. For example, the ANSI '85 library is stored in the revolve\fixlib\ansi85 directory structure.
You can have additional user-defined macro libraries for keeping customized macros and year types. Each user-defined macro library has its own subdirectory structure, which is by default under the revolve\macros directory.
Each macro library contains:
Use Administration, and then Edit year types to create a user-defined macro library. When you click Save As, you specify the name and directory for the new library. The new library is then created based on the one you are editing. The macro files referred to by the edited year type file are copied into the new library together with any supporting date handling routines. For full instructions on how to create a macro library, look up "library" in the index of the help.
The macros contain the code fragments to be inserted in the source code. They contain the code for handling date data items. For example, there is a macro for expanding data items, and a macro for contracting them. Macros can insert different code, such as in-line code or out-of-line performed sections, depending on your requirements.
The macros map the data items according to their year types. When a data item needs to be mapped in some way, the appropriate macro from the set of macros for the data item's year type is used. SmartFix takes the code fragment from the macro, replaces the macro variables with the appropriate values and inserts the code fragment into the COBOL program being fixed.
There is potentially one set of macros for each year type, each set being held in its own macro file. The filename has a .fxm extension and usually includes the name of the year type, such as yy9.fxm. In practice however, you can use the same set of macros for multiple year types. For example, year types that are the same except for their 100-year windows can refer to the same macro file, since the window can be specified as a parameter in the year type. See Edit Year Type.
SmartFix provides a set of macros for standard date formats, which you can either use as they are, or use as examples to build your own tailored macro library. For more information on the macro language, see the chapter Customizing Macros.
The macro files are held together in a macro library. If you customize or write your own macros, you store them either in your own macro library or in the current project directory. Notice, that if you store them in the current project directory, they are available to the current project only. See the chapter Customizing Macros.
When SmartFix needs a macro, it looks in the project directory first and if the required macro file isn't there, SmartFix uses the macro file from the library specified in the Fix Options tab of Options.
|Configuring Tools and Settings||Customizing Macros|