PreviousEditing Year Types and Rules Creating CategoriesNext

Chapter 7: Customizing Macros

This chapter explains how to customize the macros supplied with SmartFix.

7.1 Introduction to the Macros

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:

7.2 Introduction to Macro Files

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:

7.3 Walk Through a Sample Macro File

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.

7.3.1 Macro File Structure - Walk-through

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:

7.3.2 Default Macros - Walk-through

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:

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.

7.3.3 In-line Fix Type - Walk-through

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:

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.

7.3.4 Perform Fix Type - Walk-through

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:

Similarly, for contracting the expanded data item, the century value is removed out of line in a PERFORM section, as follows:

7.3.5 Call Fix Type - Walk-through

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:

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.

7.4 Creating Macros for a New Year Type

To create a set of macros for a new year type:

  1. Using a text editor, either write a new macro file or take a copy of an existing macro file and edit that. Edit the file according the rules in this document.

  2. Save the macro file with a filename that has the extension .fxm. The base of the filename can be anything, but it is helpful to use a name similar to the name of the year type to which the macros apply. For example, the file newyear.fxm would apply to the year type newyear.

  3. If the macro file is to be used on several projects or by several users, put the macro file in a user-defined macro library. If you do not have a user-defined macro library, create one based on an existing library. For instructions on how to do this, look up "library" in the index of the help.

    If the macro file applies to one project only and is for personal use, put it in that project's directory.

  4. At the worksheet, create the new year type that will use the macros using Edit Year Type. In the Macro set field, enter the base filename of the macro file containing the macros to use. For example, enter newyear to use macros from the file newyear.fxm. Then click Save.

  5. Click Save As , then click Save the year type definitions and assignment rules only and choose whether to save the changes with the project or in the user-defined library.

7.5 Macro Language Reference

7.5.1 Format of the Macro Files

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:

7.5.2 COBOL Dialect Keyword

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:

7.5.3 System-Defined Variables

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:

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

7.5.4 User-Defined Variables

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:

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.

7.5.5 Default Macros

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_. . . 

7.5.6 Fix Types

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
. . .

7.5.7 EXPDEFN

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:

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

7.5.8 MAPTO

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:

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

7.5.9 MAPFROM

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:

Example:

#BEGIN_MAPFROM
 IF %expvar% >= 2000
     COMPUTE %operand% = %expvar% - 2000
 ELSE
     COMPUTE %operand% = %expvar% - 1900
 END-IF
#END

7.5.10 MOVETO and MOVEFROM

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:

Examples:

#BEGIN_MOVETO
 MOVE %operand% TO %expvar%
#END
#BEGIN_MOVEFROM
 MOVE %expvar% TO %operand%
#END

7.5.11 OUTOFLINECODE

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.

7.5.12 OUTOFLINEDEFN

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

7.5.13 OUTOFLINEFIXEDDEFN

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 

7.5.14 Section Names in Out-of-line Macros

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:

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.
PreviousEditing Year Types and Rules Creating CategoriesNext