Editing Year Types and Rules | Creating Categories |
This chapter explains how to customize the macros supplied with SmartFix.
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 expand and contract the date data items according to their year types. Each year type can specify parameters to use in the macros, such as the 100-year window to assume for this year type.
When SmartFix generates a fix, it takes the code fragment from the relevant macro, replaces the macro variables with the appropriate values and inserts the code fragment into the COBOL program being fixed.
SmartFix uses the following in-line and out-of-line macros to provide the COBOL code for the corresponding action.
In-line macros:
Out-of-line macros:
You use this macro in preference to the next macro OUTOFLINEFIXEDDEFN. Use OUTOFLINEDEFN when you do not need specific level numbers for the data items.
Use OUTOFLINEFIXEDDEFN only when you need specific level numbers for the data items.
There is a set of macros associated with each year type, so that data items can be handled according to their year type. Each set is held together in one macro file. For example, there is one macro file containing the macros for handling two-digit years in numeric format, and one for handling six-digit dates in display format.
You customize the supplied macros by editing the macro file for the relevant year type. Macro files have the extension .fxm and their filenames correspond to the year types to which they apply. For example, the file yy9.fxm applies to the year type YY9, a two-digit year in numeric format.
The macro files are held together in a macro library. There is one library for the macros for fixing ANSI '85 COBOL and one for the ANSI '74 COBOL macros. Each macro library is held in its own directory structure under the fixlib directory. For example, the ANSI '85 macro library is held in the \sfplus\revolve\fixlib\ansi85 directory structure. If you customize or write your own macros, we recommend keeping them in their own library in a subdirectory of their own under \sfplus\revolve\macros directory.
Each macro file is composed of the following:
A number of system-defined variables are available for use in the macros. These variables are either set by the user, by the system, or by SmartFix itself.
You can also use your own variables in the macros in the macro file. You must define these variables at the start of the macro file and you can set default values for them there. Ultimately, when you use the finished macros to fix programs, you can override these defaults using Edit Year Type at the SmartFix worksheet.
Every macro file contains default macros, which SmartFix uses when the required macro is not available elsewhere in the macro file. You define the default macros before any other macros in the macro file.
Fix types are defined as mutually exclusive segments of the macro file, and each segment contains the macros for that fix type.
Fix types enable you to have multiple versions of any of the macros to provide different types of fixes in different situations. Ultimately, when you use the customized macros, you can choose the type of fix for each situation and get different fix code inserted.
For example, a macro file might have two fix types each containing a MAPTO macro to expand a data item. One fix type produces code that is inserted in-line with the program code being fixed. The other fix type produces code that is inserted in a perform section out-of-line with the original program.
The macros for a fix type are used instead of the defaults when the year type requires that fix type or when you explicitly select that fix type in the SmartFix dialog. If a fix type does not have the required macro, the default macro is used.
Each fix type needs a complete set of the five in-line macros. These can be defined explicitly for the fix type or inherited from the defaults.
Macro sections control the number of times the fix code is inserted into a program. They occur within the out-of-line macros only. These macros usually contain supporting code that is not needed more than once in the program being fixed. For example, an error routine is needed only once in each fixed program.
Each uniquely-named macro section is inserted only once into the program being fixed. If the name of a macro section includes a variable, the macro section is inserted once for each value of the variable.
You can put comments in macro files. These begin with a semi-colon in column 1 and end at the end of the line. They are not inserted into the COBOL file when the fix code is inserted.
This section walks through one of the supplied macro files, yy9.fxm, which contains the macros for handling data items that are the YY9 year type. These data items represent two-digit years in numeric format.
This macro file is available in the directory revolve\fixlib\ansi85. Some of the macros use additional files, which are held in the subdirectory revolve\fixlib\ansi85\source.
This section walks through the structure of the macro file, yy9.fxm. This macro file defines macros for three fix types: Inline, Call and Perform. First, the macro file states the COBOL dialect, and then declares some user variables and some default macros. Finally, it defines the macros needed for each of the fix types.
The following is a skeleton of the macro file:
#DIALECT_COBOL/ANSI85 ;----------------------------------------------------------------------- ; Declarations of user-defined variables ;----------------------------------------------------------------------- #DECLARE_WINDOW=50 Windowing year . . . ;----------------------------------------------------------------------; Default macros ;---------------------------------------------------------------------- #BEGIN_EXPDEFN %L01% %expvar% PIC %sign%9(4) %usage%. #END #BEGIN_MOVETO MOVE %operand% TO %expvar% #END #BEGIN_MOVEFROM MOVE %expvar% TO %operand% #END #BEGIN_OUTOFLINEDEFN #END #BEGIN_OUTOFLINECODE #END ;----------------------------------------------------------------------; Start of pure in-line code ;---------------------------------------------------------------------- #FIX_TYPE_INLINE In-line code #BEGIN_MAPTO . . . #BEGIN_MAPFROM . . . ;----------------------------------------------------------------------; Start of code to call subroutines ;---------------------------------------------------------------------- #FIX_TYPE_CALL In-line CALLed code #BEGIN_MAPTO . . . #BEGIN_MAPFROM . . . #BEGIN_OUTOFLINEFIXEDDEFN . . . #BEGIN_OUTOFLINECODE . . . ;----------------------------------------------------------------------; Start of code to perform fixes out of line ;---------------------------------------------------------------------- #FIX_TYPE_PERFORM Out-of-line PERFORMed code #BEGIN_MAPTO . . . #BEGIN_MAPFROM . . . #BEGIN_OUTOFLINEDEFN . . . #BEGIN_OUTOFLINECODE . . .
The macro file takes the following structure:
The default fix type in the sample macro file, yy9.fxm, defines five default macros as follows:
#BEGIN_EXPDEFN %L01% %expvar% PIC %sign%9(4) %usage%. #END #BEGIN_MOVETO MOVE %operand% TO %expvar% #END #BEGIN_MOVEFROM MOVE %expvar% TO %operand% #END #BEGIN_OUTOFLINEDEFN #END #BEGIN_OUTOFLINECODE #END
The five default macros are:
%expvar%
.
Since this macro file is for handling two-digit years in numeric format,
the expanded equivalent is defined as a four-digit data item in numeric
format. The EXPDEFN macro must always be defined as a default macro.
The two other in-line macros, MAPTO and MAPFROM, are explicitly defined for each fix type and so they are not defined as defaults.
The one other out-of-line macro, OUTOFLINEFIXEDDEFN , is defined explicitly for the fix type that uses it and so it is not defined as a default.
The In-line fix type in the supplied macro file, yy9.fxm, defines two macros, MAPTO and MAPFROM. These macros produce COBOL code that is inserted in-line with the code in the program being fixed.
The In-line fix type is defined as follows:
#FIX_TYPE_INLINE In-line code #BEGIN_MAPTO MOVE %operand% TO %expvar% IF %expvar% >= %window% ADD 1900 TO %expvar% ELSE ADD 2000 TO %expvar% END-IF #END #BEGIN_MAPFROM IF %expvar% >= 2000 COMPUTE %operand% = %expvar% - 2000 ELSE COMPUTE %operand% = %expvar% - 1900 END-IF #END
The MAPTO macro defines the COBOL windowing code to expand the date in a suspect data item into an expanded data item that includes the century. The macro uses variables as follows:
%operand%
is system maintained. It represents the name
of the suspect data item, which is a date data item that needs fixing
because it occurs in an suspect statement.
%expvar%
is system maintained. It represents the name
of the expanded data item, which is the suspect data item together with
its century.
%window%
has a default value of 50, which is set at the
start of the macro file, but you can override this in the Edit Year
Type dialog when you are fixing programs. It represents the starting
year of a 100-year window, so that a %window%
value of 50
produces a 100-year window of 1950-2049. The MAPFROM macro defines the COBOL code to contract an expanded data item back into the original data item without the century. Note, that for data items defined as PIC 9(2) DISPLAY, the macro could do a simple MOVE and rely on truncation, but this might not hold for COMPUTATIONAL data types, and so the macro subtracts the relevant century.
The Perform fix type in the supplied macro file, yy9.fxm, defines four macros: MAPTO, MAPFROM, OUTOFLINEDEFN and OUTOFLINECODE. These macros produce COBOL code that is mostly inserted out of line, such as at the end of the program being fixed or in a copybook. Some code is inserted in-line for invoking the out-of-line code.
The Perform fix type is defined as follows:
#DECLARE_WINDOW=50 Windowing year . . . #FIX_TYPE_PERFORM Out-of-line PERFORMed code #BEGIN_MAPTO MOVE %operand% TO %pre%MF-YY9-DATA%post% PERFORM %pre%EXPAND-YY9-%window%%post% MOVE %pre%MF-YY9-DATA%post% TO %expvar% #END #BEGIN_MAPFROM MOVE %expvar% TO %pre%MF-YY9-DATA%post% PERFORM %pre%CONTRACT-YY9%post% MOVE %pre%MF-YY9-DATA%post% TO %operand% #END #BEGIN_OUTOFLINEDEFN #SECTION_OOL_YY9_DATA %L01% %pre%MF-YY9-DATA%post% PIC 9(4). #END #BEGIN_OUTOFLINECODE #SECTION_OOL_YY9_EXPAND_%window% %pre%EXPAND-YY9-%window%%post% SECTION. IF %pre%MF-YY9-DATA%post% >= %window% ADD 1900 TO %pre%MF-YY9-DATA%post% ELSE ADD 2000 TO %pre%MF-YY9-DATA%post% END-IF . #SECTION_OOL_YY9_CONTRACT %pre%CONTRACT-YY9%post% SECTION. IF %pre%MF-YY9-DATA%post% >= 2000 SUBTRACT 2000 FROM %pre%MF-YY9-DATA%post% ELSE SUBTRACT 1900 FROM %pre%MF-YY9-DATA%post% END-IF . #END
For expanding a data item, the century value is calculated out of line in a PERFORM section, as follows:
%expvar%
.
%pre%EXPAND-YY9-%window%%post%
that actually expands the data item. Notice that:
%window%
is used in this COBOL
section. This means that the COBOL section needs performing once for
every window value.To limit the number of times the COBOL section is inserted, the
COBOL code is enclosed within a macro section SECTION_OOL_YY9_EXPAND_%window%
.
SmartFix uses each uniquely-named macro section only once, and so this
COBOL code is inserted only once for every window value.
%pre%MF-YY9-DATA%post%
. This data
definition is inserted only once.Similarly, for contracting the expanded data item, the century value is removed out of line in a PERFORM section, as follows:
%pre%MF-YY9-DATA%post%
;
to perform the out-of-line COBOL section that contracts the data item;
and to move the contracted item back into %operand%
.
%pre%
CONTRACT-YY9%post%
, that actually contracts the data item.
Similar to the expansion code, the macro needs to limit the number
of times the COBOL section is inserted. The %window%
variable is not used to contract the data item and so the COBOL code
is needed only once. To do this, the COBOL code is enclosed within a
macro section SECTION_OOL_YY9_CONTRACT
, and SmartFix
uses this macro section only once, and so inserts the COBOL code only
once.
%pre%MF-YY9-DATA%post%
. The data
definition has already been inserted to support the expansion code and
it is not inserted again because a macro section named SECTION_OOL_YY9_DATA
has already been used.The Call fix type in the supplied macro file, yy9.fxm, defines four macros: MAPTO, MAPFROM, OUTOFLINEFIXEDDEFN and OUTOFLINECODE. These macros produce COBOL code that calls a subroutine to expand a data item. In addition, the fix type produces out-of-line COBOL code to handle an error condition returned from the subroutine.
The fix type also requires the subroutine, y2kdate.cbl and two copybooks y2klink.cpy and y2kerror.cpy. These files are available in revolve\fixlib\ansi85\source.
A number of variables are also used in the macros and these are defined at the start of the macro file, as follows:
#DECLARE_WINDOW=50 Windowing year #DECLARE_SIGN= 'S' for signed numeric #DECLARE_WINDOWID=1 Identifier for window year in Y2KDATE #DECLARE_DATEFORMAT=YY9 Date format passed to Y2KDATE #DECLARE_CALLNAME=Y2KDATE User name for called routine (Y2KDATE) #DECLARE_ERRORSECTION=Y2KDATE-ERROR Section name for Y2KDATE error routine #DECLARE_PARMNAME=Y2KDATE-PARM 01-Level name for Y2KDATE Parameter block #DECLARE_PARMCOPY=Y2KLINK Copy book name for SF2KDATE Parameter block #DECLARE_ERRORCOPY=Y2KERROR Copybook containing user error response . . .
The Call fix type itself is defined as follows:
#FIX_TYPE_CALL In-line CALLed code #BEGIN_MAPTO MOVE %operand% TO %expvar% MOVE %windowid% TO Y2K-WINDOW-ID MOVE '%dateformat%' TO Y2K-DATE-FORMAT MOVE 4 TO Y2K-FIELD-LEN MOVE 'E' TO Y2K-REQUEST MOVE '%usage% ' TO Y2K-FIELD-USAGE CALL '%callname%' USING %parmname%, %expvar% IF RETURN-CODE > 4 PERFORM %errorsection% END-IF #END #BEGIN_MAPFROM IF %expvar% >= 2000 COMPUTE %operand% = %expvar% - 2000 ELSE COMPUTE %operand% = %expvar% - 1900 END-IF #END #BEGIN_OUTOFLINEFIXEDDEFN #SECTION_CALL_PARMS 01 %parmname%. COPY %parmcopy%. 01 MF-Y2K-MESSAGE PIC X(80). #END #BEGIN_OUTOFLINECODE #SECTION_CALL_ERROR ***************************************************************** * CALL SMARTFIX DATE ROUTINE TO RETURN ERROR MESSAGE * * CHANGE THE SMARTFIX MACRO, THE COPYBOOK OR THE GENERATED * * PROGRAM TO ALTER THE RESPONSE TO THE ERROR * ***************************************************************** %errorsection% SECTION. MOVE 'M' TO Y2K-REQUEST CALL '%callname%' USING %parmname% MF-Y2K-MESSAGE IF RETURN-CODE NOT EQUAL 0 MOVE '%callname%: MESSAGE NOT AVAILABLE' TO MF-Y2K-MESSAGE END-IF COPY %errorcopy%. #END
For expanding a data item, the century value is not calculated in line but in a called subroutine, as follows:
%parmname%
; and the
name of the COBOL section, %errorsection%
, to handle the
error condition.
%expvar%
.
The subroutine itself is a separate COBOL program that handles the expansion of all the supplied year types and expects a parameter identifying the date format of the data item.
%errorsection%
, if the
subroutine returns an error. %parmname%
is defined as
a level 01 data item. Notice that the group level data item is hard
coded as level 01, instead of taking its level number from a
variable.
%parmcopy%
,
and covers such data items as Y2K-DATE-FORMAT, Y2K-REQUEST
and Y2K-FIELD-USAGE
.
MF-Y2K-MESSAGE
, is used in the
OUTOFLINECODE macro and so needs defining here. Notice that it too
is hard coded as level 01, instead of taking its level number from a
variable.%errorsection%
,
that handles the error condition. In this case, the code sets the
relevant parameter to indicate the error and then calls the subroutine,
which then returns the message in the data item MF-Y2K-MESSAGE
.
Notice that the macro also uses the copybook, %errorcopy%
,
which displays the relevant error message.
In this Call fix type, the MAPFROM macro, which contracts the expanded data item, is inserted as in-line code the same as in the Inline fix type.
To create a set of macros for a new year type:
If the macro file applies to one project only and is for personal use, put it in that project's directory.
The formatting of the macro file determines the formatting of the COBOL code. The user can specify the required formatting on the COBOL Formatting tab of SmartFix Options. To generate and align the COBOL code in the way you intend, conform to the following rules when coding or changing the macro file:
The DIALECT keyword is available for stating the COBOL dialect used in the macro file. This has the following advantages over specifying the dialect elsewhere, such as in Options or in the year type:
The dialect keyword is examined when the macros are loaded, which happens when you open the worksheet and when you change the macro library in Fix Options. When the macros are loaded, the first dialect found in the macro files is taken as the dialect to use. If none of the loaded macro files specify the COBOL dialect, ANSI '85 is assumed.
The dialect setting affects the way SmartFix fixes statements, since the fix depends on the COBOL syntax available. For example, PERFORM statements can be fixed in-line using ANSI '85 syntax, but are fixed by generating out-of-line PERFORM sections for ANSI '74 COBOL.
Format:
#DIALECT_dialect
Rules:
dialect
is COBOL/ANSI74 or COBOL/ANSI85
There are a number of system variables available for you to use in the macros. The value of these variables might be set by the user or by SmartFix or the system. When SmartFix generates the fix code, it substitutes the value for the variable name.
Variables:
%date%
- the system date.
%expvar%
- the generated name of the expanded data
item. Generally, this is the original data item name, prefixed by the
value of %pre%
and suffixed by the value of %post%
.
SmartFix ensures that the generated name does not exceed the length of a
valid COBOL name.
%L01%
- The initial COBOL level-number for generated
Working-Storage items. The user specifies the value for this variable in
the Data tab of SmartFix Options.
%L02%, %L03%
and so on - The lower COBOL level-numbers
for generated working storage items %L01%
. The user
specifies the values for these variables in the Data tab of
SmartFix Options.
%operand%
- the name of the suspect data item.
%pic%
- the COBOL PICTURE clause of the suspect data
item. This variable is available only in the macro EXPDEFN.
%pre%
- the prefix that is added to data item names to
generate the names for expanded data items. The user specifies the value
for this variable in the Data tab of SmartFix Options.
%post%
- the suffix that is added to data item names to
generate the names for expanded data items. The user specifies the value
for this variable in the Data tab of SmartFix Options.
%usage%
- the COBOL usage of the suspect data item.
This variable is available only in the macro EXPDEFN.
%userid%
- the user's logon id. This field is always
available on Windows NT, and is available on Windows 95 machines when
the user logs on to the machine.
Rules:
Example:
Given the following line in a macro file:
PERFORM %pre%EXPAND-YY9-%window%%post%
Where the variables have the following values:
%pre%
null %window%
50 %post%
-Y2K
SmartFix produces the following code:
PERFORM EXPAND-YY9-50-Y2K
You can use your own variables in the macros in the macro file. SmartFix substitutes the value of the variable for the variable name when it generates the fix code.
You define these variables at the start of the macro file, using the #DECLARE statement.
Format:
#DECLARE_variable-name=variable-value variable-description
Rules:
Do not use the same name as a system variable. If you do, it overrides the system variable and might produce unexpected results.
The same variable names can be defined in more than one macro file.
Variables with null values (those without a value set) are ignored when the fix code is inserted.
You can omit the equals sign if you are not setting a default value.
Examples:
#DECLARE_WINDOW=50 Windowing year #DECLARE_WINDOWID=1 Identifier for window year in Y2KDATE #DECLARE_DATEFORMAT=YY9 Date format passed to Y2KDATE #DECLARE_CALLNAME=Y2KDATE User name for called routine (Y2KDATE) #DECLARE_ERRORSECTION=Y2KDATE-ERROR Section name for Y2KDATE error routine #DECLARE_PARMNAME=Y2KDATE-PARM 01-Level name for Y2KDATE Parameter block #DECLARE_PARMCOPY=Y2KLINK Copy book name for SF2KDATE Parameter block #DECLARE_ERRORCOPY=Y2KERROR Copybook containing user error response #DECLARE_SIGN= 'S' for signed numeric
Note that SIGN is not assigned an initial value, because there is a space immediately after the equals (=) sign. You can omit the equals sign and achieve the same result.
Every macro file has an unnamed fix type, the default fix type, which contains default macros. These macros are common to all the fix types and they apply when the required macro is not defined for the relevant fix type.
Rules:
Example:
#DECLARE_. . . #BEGIN_EXPDEFN %L01% %expvar% PIC %sign%9(4) %usage%. #END #BEGIN_MOVETO MOVE %operand% TO %expvar% #END #BEGIN_MOVEFROM MOVE %expvar% TO %operand% #END #BEGIN_OUTOFLINEDEFN #END #BEGIN_OUTOFLINECODE #END #FIX_TYPE_. . .
Fix types are mutually exclusive segments of the macro file, each segment containing the macro definitions for that fix type.
Fix types provide alternative ways of fixing statements for different situations. For example, one fix type might insert the fix code in-line with the program code being fixed and another fix type might insert a performed section at the end of the program.
A fix type starts with a FIX_TYPE declaration and ends with the next FIX_TYPE declaration or the end of the macro file.
Format:
#FIX_TYPE_fix-type-name fix-type-description
Rules:
Examples:
#FIX_TYPE_INLINE In-line code #BEGIN_MAPTO . . . #FIX_TYPE_PERFORM Out-of-line PERFORMed code #BEGIN_MAPTO . . . . . . #BEGIN_OUTOFLINEDEFN . . . . . . #BEGIN_OUTOFLINECODE . . . . . . #FIX_TYPE_CALL In-line CALLed code #BEGIN_MAPTO . . .
The EXPDEFN macro defines the COBOL code to generate data definitions in Working Storage for the expanded data items. SmartFix generates only one data definition for each expanded data item, no matter how many times the suspect data item is expanded in the program.
Use NOEXPVAR when you do not want to automatically generate an expanded version of a date data item. For example, you might do this where a windowing fix is not appropriate for a data item, and yet you still want to record the data item as suspect in the worksheet.
Format:
#BEGIN_EXPDEFN NOEXPVAR %Lnn% picture-clause usage. #END
Rules:
%expvar%
macro variable is not defined. If a
macro attempts to use it, it produces incorrect code.
%Lnn%
defines the initial COBOL level number of the
expanded data item, %expvar%
. Use the system variable
%L01%
or %L03%
and so on.
%expvar%
is the system-generated name for the expanded
data item. Generally, it is made up the name of the original data item
with the %pre%
prefix and %post%
suffix.
SmartFix might change the name to ensure that the generated name does
not violate the COBOL rules for the lengths of data item names.
%usage%
is the USAGE clause of the
data item's PICTURE. If you use the %usage%
system
variable, the COBOL usage of the original date data item is used in the
new data definition.
Examples:
In the following example from the supplied macro file, yy9.fxm, the EXPDEFN macro generates the code to define a data item for four-digit years in numeric format:
#BEGIN_EXPDEFN %L01% %expvar% PIC 9(4) %usage%. #END
In the following example from the supplied macro file, ymdx.fxm, the EXPDEFN macro generates the code to define a data item for eight-digit dates in display format:
#BEGIN_EXPDEFN %L01% %expvar%. %L02% %pre%MF-CC%post% PIC XX. %L02% %pre%MF-YYMMDD%post%. %L03% %pre%MF-YY%post% PIC XX. %L03% FILLER PIC X(4). #END
The MAPTO macro defines the COBOL windowing code to expand the date in a suspect data item into an expanded data item that includes the century. SmartFix inserts this code before suspect statements containing a suspect data item.
Format:
#BEGIN_MAPTO expansion-code #END
Rules:
%operand%
, and to store this
century together with the original date in the expanded data item,
%expvar%
.
%expvar%
is required in
Working-Storage, and SmartFix uses the EXPDEFN macro to create it. Examples:
In the following example, from the supplied macro file yy9.fxm, the suspect data item is a two-digit year in numeric format. The COBOL code to calculate the value of the expanded data item is inserted in line with the program code being fixed.
#FIX_TYPE_INLINE In-line code #BEGIN_MAPTO MOVE %operand% TO %expvar% IF %expvar% >= %window% ADD 1900 TO %expvar% ELSE ADD 2000 TO %expvar% END-IF #END
In the following example, from the supplied macro file yy9.fxm,
the value of the expanded data item is not calculated in line but out of
line in a PERFORM section. The MAPTO macro inserts the necessary COBOL
code in line to move the suspect data item into a temporary generic data
item, to invoke the out-of-line perform section to perform the expansion,
and to move the expanded item into %expvar%
.
Note, that you also need to write an OUTOFLINECODE macro containing the
perform section, %pre%EXPAND-YY9-%window%%post%
, that
actually expands the data item. You will also need an OUTOFLINEDEFN macro
to define the temporary generic data item, %pre%MF-YY9-DATA%post%
.
#FIX_TYPE_PERFORM Out-of-line PERFORMed code #BEGIN_MAPTO MOVE %operand% TO %pre%MF-YY9-DATA%post% PERFORM %pre%EXPAND-YY9-%window%%post% MOVE %pre%MF-YY9-DATA%post% TO %expvar% #END
In the following example, from the supplied macro file yyx.fxm, the suspect data item is a two-digit year in alphanumeric format. The COBOL code to calculate the value of the expanded data item is inserted in-line in the program being fixed.
#FIX_TYPE_INLINE In-line code #BEGIN_MAPTO MOVE %operand% TO %pre%MF-YY%post% OF %expvar% IF %pre%MF-YY%post% OF %expvar% >= '%window%' MOVE '19' TO %pre%MF-CC%post% OF %expvar% ELSE MOVE '20' TO %pre%MF-CC%post% OF %expvar% END-IF #END
In the following example, from the supplied macro file yyx.fxm, the value of the expanded data item is not calculated in line but in a called subroutine. The MAPTO macro inserts the necessary COBOL code in-line to set up the parameters to pass to the subroutine, to call the subroutine, and to perform a COBOL section if the subroutine returns an error.
Note that you also need to write the subroutine that expands the data item. You will also need an OUTOFLINECODE macro containing the perform section, %errorsection%, to handle the error condition.
#FIX_TYPE_CALL In-line CALLed code #BEGIN_MAPTO MOVE %operand% TO %pre%MF-YY%post% OF %expvar% MOVE '00' TO %pre%MF-CC%post% OF %expvar% MOVE %windowid% TO Y2K-WINDOW-ID MOVE '%dateformat%' TO Y2K-DATE-FORMAT MOVE 4 TO Y2K-FIELD-LEN MOVE 'E' TO Y2K-REQUEST MOVE 'DISPLAY' TO Y2K-FIELD-USAGE CALL '%callname%' USING %parmname%, %expvar% IF RETURN-CODE > 4 PERFORM %errorsection% END-IF #END
The MAPFROM macro defines the COBOL code to contract an expanded data item back into the original data item without the century. SmartFix inserts this code after a subtract statement only where the result is not a date, such as in the statement:
SUBTRACT YY-1 FROM YY-2
Format:
#BEGIN_MAPFROM contraction-code #END
Rules:
%expvar%
, and to move the value back
to the original date data item, %operand%
.Example:
#BEGIN_MAPFROM IF %expvar% >= 2000 COMPUTE %operand% = %expvar% - 2000 ELSE COMPUTE %operand% = %expvar% - 1900 END-IF #END
The MOVETO macro defines the COBOL code to move a value to the expanded data item from the suspect date data item without changing the value.
Similarly, the MOVEFROM macro defines the COBOL code to move a value from the expanded data item back into the suspect date data item, truncating the value if the expanded data item is larger.
SmartFix does not use the MOVETO macro automatically. The user can select it explicitly in the SmartFix dialog, in the Before column of the operand table.
Format:
#BEGIN_MOVETO move-to-code #END #BEGIN_MOVEFROM move-from-code #END
Rules:
%expvar%
, from the suspect data item,
%operand%
, without change.
%expvar%
, back into the suspect data
item, %operand%
, truncating the value if the expanded data
item is larger. Examples:
#BEGIN_MOVETO MOVE %operand% TO %expvar% #END #BEGIN_MOVEFROM MOVE %expvar% TO %operand% #END
The OUTOFLINECODE macro defines one or more complete COBOL sections or paragraphs to be performed out of line. SmartFix inserts these COBOL sections or paragraphs if an in-line macro includes a PERFORM statement referring to the COBOL section.
For example, a MAP_TO macro might insert a PERFORM statement before each suspect statement to expand the relevant data item. Alternatively, another MAP_TO macro might insert a CALL statement before each suspect statement, and then perform an error section if the called routine gives a bad return code. In both examples, the OUTOFLINECODE macro is needed to insert the relevant perform section into the program being fixed.
The OUTOFLINECODE macro usually contains supporting code that is not needed every time the macro is used. For example, an error routine or a generic COBOL section is needed once only in each program being fixed. To control the number of times that the code is inserted, use a macro section. Each uniquely-named macro section is inserted only once into a program, so to insert the code only once, use the same macro section in every macro file. See Section Names in Out-of-line Macros for full details.
We recommend that you make out-of-line code generic and not specific to the suspect statement being fixed. If you make it specific, the COBOL section name needs to include a variable related to that suspect statement, and the name might exceed the maximum length allowed in COBOL.
Format:
#BEGIN_OUTOFLINECODE #SECTION_macro-section-name COBOL-section-name SECTION. perform-code . . . #END
Rules:
Examples:
In the following example, a COBOL section, %errorsection%
,
is generated to call a subroutine to return an error message. If exactly
the same macro section, #SECTION_CALL_ERROR
, is defined in
all the macro files, SmartFix inserts the COBOL section, %errorsection%
,
only once into the program being fixed.
#FIX_TYPE_CALL In-line CALLed code . . . #BEGIN_OUTOFLINECODE #SECTION_CALL_ERROR ************************************************************* * CALL SMARTFIX DATE ROUTINE TO RETURN ERROR MESSAGE * * CHANGE THE SMARTFIX MACRO, THE COPYBOOK OR THE GENERATED * * PROGRAM TO ALTER THE RESPONSE TO THE ERROR * ************************************************************* %errorsection% SECTION. MOVE 'M' TO Y2K-REQUEST CALL '%callname%' USING %parmname% MF-Y2K-MESSAGE IF RETURN-CODE NOT EQUAL 0 MOVE '%callname%: MESSAGE NOT AVAILABLE' TO MF-Y2K-MESSAGE END-IF COPY '%errorcopy%'. #END
In the following example, a COBOL section is generated for each 100-year
window used in the application program. Here, the section name contains
the variable %window%
. Each value of %window%
generates another COBOL section, which expands the date in a data item
using that window:
#FIX_TYPE_PERFORM Out-of-line PERFORMed code . . #BEGIN_OUTOFLINECODE #SECTION_OOL_YY9_EXPAND_%window% %pre%EXPAND-YY9-%window%%post% SECTION. IF %pre%MF-YY9-DATA%post% >= %window% ADD 1900 TO %pre%MF-YY9-DATA%post% ELSE ADD 2000 TO %pre%MF-YY9-DATA%post% END-IF.
The OUTOFLINEDEFN macro defines the COBOL code that generates the Working-Storage data definitions required for the out-of-line fixes. For example, this macro might generate the data definitions required for the OUTOFLINECODE macro or for the parameters passed to a called subroutine.
SmartFix inserts the data definitions when using the corresponding macro for the out-of-line fix.
The data definitions required for out-of-line fixes usually need inserting only once in each program being fixed and not every time the macro is used. To control the number of times that the data definitions are inserted, use macro sections. Each uniquely-named macro section is inserted only once into a program, so to insert the data definition only once, use the same macro section in every macro file. See Section Names in Out-of-line Macros for full details.
The OUTOFLINEDEFN macro is similar to the OUTOFLINEFIXEDDEFN macro, except that the OUTOFLINEFIXEDDEFN macro inserts the Working-Storage data definitions at explicitly specified levels, and not at levels defined by a variable, such as %L01%. We recommend that you:
Format:
#BEGIN_OUTOFLINEDEFN #SECTION_macro-section-name data-definitions . . . #END
Rules:
Examples:
In the following example, the data definitions for the subroutine's parameters are needed only once. They will be inserted only once if every macro file that uses these parameters, %parmname%, defines exactly the same code in a macro section with the same section name, which in this example is CALL_PARMS:
#FIX_TYPE_CALL In-line CALLed code . . . #BEGIN_OUTOFLINEDEFN #SECTION_CALL_PARMS %L01% %parmname%. COPY %parmcopy%. %L01% MF-Y2K-MESSAGE PIC X(80). #END #BEGIN_OUTOFLINECODE . . . CALL '%callname%' USING %parmname% MF-Y2K-MESSAGE . . . #END
In the following example, the OUTOFLINECODE macro uses a temporary data item, %pre%MF-YY9-DATA%post%. The OUTOFLINEDEFN macro creates the data definition for this data item so that this code is inserted into the Working-Storage of the program being fixed.
#FIX_TYPE_PERFORM Out-of-line PERFORMed code . . . #BEGIN_OUTOFLINEDEFN #SECTION_OOL_YY9_DATA %L01% %pre%MF-YY9-DATA%post% PIC 9(4). #END #BEGIN_OUTOFLINECODE . . . IF %pre%MF-YY9-DATA%post% >= %window% ADD 1900 TO %pre%MF-YY9-DATA%post% ELSE . . . #END
The OUTOFLINEFIXEDDEFN macro, like the OUTOFLINEDEFN macro, defines the COBOL code that generates the Working-Storage data definitions required for the out-of-line fixes.
The difference between the two macros is that the OUTOFLINEFIXEDDEFN macro inserts the Working-Storage data definitions at explicitly specified levels, and not at levels defined by a variable, such as %L01%. We recommend that you:
The data definitions required for out-of-line fixes usually need inserting only once in each program being fixed and not every time the macro is used. To control the number of times that the data definitions are inserted, use macro sections. Each uniquely-named macro section is inserted only once into a program, so to insert the data definition only once, use the same macro section in every macro file. See Section Names in Out-of-line Macros for full details.
Format:
#BEGIN_OUTOFLINEFIXEDDEFN #SECTION_macro-section-name data-definitions . . . #END
Rules:
Examples:
In the following example, the data definitions for the subroutine's parameters are needed only once. They will be inserted only once if every macro file that uses these parameters, %parmname%, defines exactly the same code in a macro section with the same section name, which in this example is CALL_PARMS:
#FIX_TYPE_CALL In-line CALLed code . . . #BEGIN_OUTOFLINEFIXEDDEFN #SECTION_CALL_PARMS 01 %parmname%. COPY %parmcopy%. 01 MF-Y2K-MESSAGE PIC X(80). #END #BEGIN_OUTOFLINECODE . . . CALL '%callname%' USING %parmname% MF-Y2K-MESSAGE . . . #END
The code defined in the OUTOFLINEDEFN and OUTOFLINECODE macros is often needed only once in each program. For example, a generic COBOL section is needed only once in each program, no matter how many times or from where the COBOL section is performed.
To ensure that an out-of-line fix is inserted only once, put the fix within a macro section with a unique name. Each uniquely-named macro section is inserted only once.
Macro sections are not related to COBOL sections. They enable you to control the number of times code is inserted as follows:
EXPAND_YY_%window%
).
Format:
#SECTION_macro-section-name
Rules:
Examples:
In the following example, the code in the macro section SECTION_OOL_YY9_DATA is inserted only once into each COBOL program being fixed.
#BEGIN_OUTOFLINEDEFN #SECTION_OOL_YY9_DATA . . .
In the following example, the code in the macro section SECTION_OOL_YY9_EXPAND_%window%
is inserted once for each value of %window%
.
#BEGIN_OUTOFLINECODE #SECTION_OOL_YY9_EXPAND_%window% %pre%EXPAND-YY9-%window%%post% SECTION. . . .
If this macro section relates to two year types, one that is windowed on
1950 (%window%
=50) and one that is windowed on 1967 (%window%
=67),
the following two COBOL sections are inserted into the program if it uses
data items of both year types: Y2K-EXPAND-YY9-50-Y2K SECTION.
Y2K-EXPAND-YY9-67-Y2K SECTION.
Where:
%window%
is 50 and 67
%pre% is Y2K-
%post% is -Y2K
For more examples, see the examples for the OUTOFLINEDEFN and OUTOFLINECODE macros.
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Editing Year Types and Rules | Creating Categories |