Previous Reporting on the Date Issues Group Worksheet and Administration Next

Chapter 10: Generating and Editing Fixes

This tutorial in this chapter demonstrates how to fix the the year 2000 problems in the sample application.

10.1 Overview

You have identified all the statements that need to be fixed and have assigned year types to the relevant data items, and this information is held in the worksheet. Each statement in the worksheet has a fix automatically generated, and you now need to systematically check each fix and either approve or adjust it as necessary.

The statements in the worksheet are initially colored in blue or red. The blue ones are marked with the fix status Auto in the Status column, meaning that a fix is automatically generated for them. Statements for which a fix is not generated are in red. As you work through approving the statements you change their status to Fixed and they are then colored green.

In this tutorial, you work through each problem statement in turn. You examine the automatically generated fixes in the worksheet, verifying each one and adjusting them as necessary. Finally you apply the fixes to the source.

10.2 Preparation

This section explains how to open the appropriate worksheet for the Tour project.

10.2.1 Running the Tutorial for the First Time

Set fix mode as follows:

  1. Click Options on the worksheet.

  2. On the Worksheet tab, click Find and fix.

    All the fixing options on all the worksheet tabs are now enabled, so that you can customize the way to generate fixes.

    Click OK.

  3. Reinstate the Status column into the Statements tab of the worksheet. To do this right click in the column heading and use Customize columns.

  4. Use Display Filters to show just the statements that need fixing, which are those with the A-Yes category.

    The worksheet shows 17 filtered statements.

  5. If you stopped following the tutorials, open the Tour project and the default worksheet, as before, and check that your options are set correctly for the tutorials. For details, see the sections Setting the Analysis Tools Options and Setting the Worksheet Options in the chapter Finding and Adding Dates to the Worksheet.

The worksheet should contain 53 data items and 119 statements.

10.2.2 Repeating the Tutorial

If you have already started this tutorial and now want to restart it, you need to reopen the backup worksheet that you made at the end of the previous tutorial. To do this:

  1. At the worksheet, click Load Load from File and select the latest backup worksheet, Tour\EndofChap8.mdb, or whatever name you used for your latest backup.

    Depending on how you have Windows set up, the worksheet names are displayed with or without the .mdb extension.

  2. Click No to overwrite the existing project worksheet that you no longer want, and click Yes to confirm overwriting.

    The title bar of the worksheet now shows Worksheet - Tour, and you can work on this leaving the backup EndofChap8.mdb intact in case you need it again.

  3. Check that your options are set correctly for the tutorials, as described in the sections Setting the Analysis Tools Options and Setting the Worksheet Options in the chapter Finding and Adding Dates to the Worksheet.

  4. Make sure that fix mode is set on the Worksheet tab of Options, by clicking Find and fix and then OK.

The worksheet contains 53 data items and 119 statements.

10.3 Reviewing the Fix for a SUBTRACT Statement

This section describes the fix that is automatically generated for one of the SUBTRACT statements.

  1. At the Statements tab of the worksheet, double click the statement that starts subtract p-start-year. To see the line numbers, widen the Location column by dragging its heading.

  2. In the statement that appears at the top left, three operands are shown in blue. Two of them are marked with a green tick, meaning that fixes are automatically generated for them.

  3. In the operand table at the top right, notice how the operand p-start-year is treated:

  4. Notice that the operand rd-end-yy is fixed in essentially the same way as p-start-year.

  5. Notice that the operand sub1 has the year type NOTDATE. It is not a year. It is the difference between two years, just a duration, and so does not need fixing.

  6. In the New Code tab, examine the fix and how the two date operands are being expanded before the statement. For example:
    *Begin Fix
        move p-start-year to sf2k-p-start-year  
                            *> expand p-start-year
        if sf2k-p-start-year >= 50
           add 1900 to sf2k-p-start-year
        else
           add 2000 to sf2k-p-start-year
        end-if
        move rd-end-yy to sf2k-rd-end-yy        
                            *> expand rd-end-yy
        if sf2k-rd-end-yy >= 50
           add 1900 to sf2k-rd-end-yy
        else
           add 2000 to sf2k-rd-end-yy
        end-if
        subtract sf2k-p-start-year -1 from      
                sf2k-rd-end-yy giving sub1
                            *> subtraction
    *End Fix

    The in-line comments marked with *> do not appear in your code. They are included here to help explain the new code.

  7. Click the Working-Storage tab to see the additional data declarations needed for the expanded versions of the suspect data items.

  8. Click the Notes tab to see notes on potential additional problems with this statement. Click the note for more information in the help.

  9. At the bottom left, change the Status from Auto to Fixed to indicate that you approve the fix.

  10. Click Save to save the fix in the worksheet and to return to the worksheet.

This statement, when deselected, is shown in green now that it has an approved fix ready for applying to the source. The statement has not actually been fixed yet, nor has the source been changed, but a fix has been generated for the statement.

10.4 Reviewing a Negative ADD Statement

This section shows another fix that is automatically generated for a statement that adds a negative literal, which is effectively a subtraction. It is possible with some values that this subtraction could cause a problem, so the statement needs fixing.

  1. In the worksheet, double click the statement that starts ADD P-START-YEAR.

  2. Examine the original statement at the top left. Since p-start-year represents a 2-digit year and the p-years-to-report represents a period of years, the data item tmp-end-yy holds a 2-digit year.

  3. Change the status from Auto to Fixed, to enable you to change the fix.

  4. Update the data item tmp-end-yy in the operand table at the top right, as follows:

  5. Save the fix in the worksheet, by clicking Save.

The fix is now generated correctly for this ADD statement and is shown in green, and the status is set to Fixed.

There are now 2 green fixed and approved statements in the worksheet.

10.5 Fixing a Statement that Uses 1900

This section shows another fix that SmartFix automatically generates and how you can edit the generated code to suit the program being fixed.

  1. In the worksheet, double-click the statement starting ADD 1900 P-START-YEAR.

  2. Examine the original statement and notice that it is expanding a two-digit year to a four-digit year by adding 1900. This is not correct for years in the 2000s, and this statement needs fixing. In the New Code tab, notice that SmartFix correctly expands p-start-year, and then goes on to add 1900, which is not what the original statement intended.

  3. Change the status from Auto to Fixed, to enable you to change the fix.

  4. In the New Code tab, comment out the penultimate line, which begins add 1900 sf2k-p-start-year, by putting an asterisk in column 7. Add the following line immediately after that commented line:

    move sf2k-p-start-year to tmp-yyyy

    The new code should now be:

    *Begin Fix
         move p-start-year to sf2k-p-start-year     *> expand p-start-year
         if sf2k-p-start-year >= 50
            add 1900 to sf2k-p-start-year
         else
            add 2000 to sf2k-p-start-year
         end-if 
    *     add 1900 sf2k-p-start-year to tmp-yyyy     *> original statement
         move sf2k-p-start-year to tmp-yyyy         *> replaces original
    *End Fix 

    The in-line comments marked with *> do not appear in your code. They are included here to help explain the new code.

  5. Save the fix in the worksheet, by clicking Save.

This statement is now shown in green and has a suitable fix generated. Notice that the status of the statement is Fixed (generated and manually edited) because you generated the fix for p-start-year and you also edited the code in the New Code tab.

There are now 3 green fixed statements in the worksheet.

10.6 Fixing a PERFORM Statement Header

This section shows how the header of a PERFORM statement is fixed.

  1. Double click the statement that starts PERFORM VARYING TMP-YY.

  2. In the statement which appears at the top left, notice that tmp-yy occurs twice. All the operands are ticked and fixed.

    Each of the operands needs handling differently. For a full explanation see the section PERFORM VARYING in the chapter Year 2000 Problems and Solutions in the User Guide.

  3. In the operand table at the top right, notice how the operand tmp-yy is treated:

  4. In the operand table at the top right, notice how the operand p-start-year is treated:

    The Before column shows that p-start-year is expanded before the statement. This is needed so that the four-digit version can be assigned to sf2k-tmp-yy ready for the comparison with sf2k-tmp-end-yy.

  5. Notice that tmp-end-yy has the year type YY9 in the Treat as column of the operand table. The Before column shows that tmp-end-yy is expanded before the statement, so that it can be compared with sf2k-tmp-end-yy.

  6. Change the status from Auto to Fixed.

  7. View the fix that is now generated in the New Code tab. The new code should be:
    *Begin Fix
          move tmp-yy to sf2k-tmp-yy        *> expand tmp-yy
          if sf2k-tmp-yy >= 50
             add 1900 to sf2k-tmp-yy
          else
             add 2000 to sf2k-tmp-yy
          end-if
          move p-start-year to sf2k-p-start-year    *> expand p-start-year
          if sf2k-p-start-year >= 50
             add 1900 to sf2k-p-start-year
          else
             add 2000 to sf2k-p-start-year
          end-if
          move tmp-end-yy to sf2k-tmp-end-yy        *> expand tmp-end-yy
          if sf2k-tmp-end-yy >= 50
             add 1900 to sf2k-tmp-end-yy
          else
             add 2000 to sf2k-tmp-end-yy
          end-if
          perform varying sf2k-tmp-yy from sf2k-p-start-year by 1   *>new perform
                  until sf2k-tmp-yy > sf2k-tmp-end-yy
          if sf2k-tmp-yy >= 2000                     *> contract tmp-yy
             compute tmp-yy = sf2k-tmp-yy - 2000
          else
             compute tmp-yy = sf2k-tmp-yy - 1900
          end-if 
    *End Fix 

    The in-line comments marked with *> do not appear in your code. They are included here to help explain the new code.

    This fix is now complete. In some programs, you might need to add some code at the end of the performed code to re-expand the operands so that they can be varied and compared correctly each time through the PERFORM loop. In this program, you don't need to add any extra code, because none of the operands are modified in the performed code. For a full explanation see the section PERFORM VARYING in the chapter Year 2000 Problems and Solutions in the User Guide

  8. Save the fix in the worksheet, by clicking Save.

The fix is now generated correctly for the perform statement header and is shown in green and has the status Fixed.

There are now 4 green fixed statements in the worksheet.

10.7 Fixing the COMPUTE Statements

In this section you fix the COMPUTE statements.

  1. Select all the unfixed COMPUTE statements, and click SmartFix.

  2. Examine the fix for the first statement. The year data item yy is expanded before the COMPUTE statement. However, the result produced from the computation is the number of months since the year 0000, which is not what the original statement intended. To produce the correct result, the months since 1900, you need to subtract 1900 from the expanded year before performing the computation, as described below.

  3. Change the status of the statement to Fixed.

  4. To produce the correct result, the months since 1900, add the following statement immediately before the computation:
     subtract 1900 from sf2k-yy005769q 

    sf2k-yy005769q is the unique name generated for the expanded operand yy of yymmdd. If the generated name is slightly different in your case, use the expanded name shown in the Expanded Data Item column in the operand table.

  5. Click Save to save the fix.

  6. Click Next to go to the other COMPUTE statement. Fix this statement in the same way and click Save when you have finished.

  7. Click Next to go to the statement starting COMPUTE SUB2. Set the year type for SUB2 to YY9 and click Save when you have finished.

  8. Click Cancel to return to the worksheet.

The fixes are now generated correctly for the COMPUTE statements and are shown in green. Notice that the status of the statements is Fixed (generated and manually edited) because you started with the generated fix and then edited the code in the New Code tab.

There are now 7 green fixed and approved statements in the worksheet.

10.8 Leaving Statements To Fix Manually

Although SmartFix can generate a fix for most statements, there are some statements that have wider implications and potentially need recoding. For example, you might decide to expand the data in a file, so that the statements that use that data do not need fixing at all.

This section shows how to mark statements so that they are not fixed automatically but left for you to fix manually.

  1. Double click the unfixed PERFORM statement, which starts PERFORM READ-CONTRACT-FILE.

  2. Change the status from Auto to Not fixed.

  3. Click Save.

The unfixed PERFORM statement is now shown in red.

10.9 Setting Options for Out-of-Line Code Fixes

This section shows some of the options you can set to customize the layout and style of the code fixes. In particular, you change the type of fix generated so that instead of inserting code in-line with the program being fixed, the fix is inserted out-of-line as a perform section.

  1. At the worksheet, click Options.

  2. Go to the Fix Options tab and in Default fix type, choose PERFORM. From now on, the fixes are generated as out-of-line perform sections. Minimal code is inserted in-line, and puts the bulk of the fix in a perform section elsewhere, either at the end of the program or in a copybook.

  3. You can explore the other tabs, but we don't need to change any options for now. Click Help Help at the top right, and then click any of the options to display help on that option.

  4. Click OK.

10.10 Approving the Remaining Fixes

In this section, you work through the remaining statements in turn, examining the generated fixes and approving them.

  1. Select the remaining 9 unfixed statements in blue (those with status Auto) in the worksheet, which are three ADD, two IF and four SUBTRACT statements.

    To do this, sort the statements first into statement order and second into status order and then select the statements with Auto status.

  2. Click SmartFix.

  3. Examine the first fix and view the New Code, Working Storage and Out Of Line tabs to see how the perform section, sf2k-expand-yy9-50 or sf2k-expand-ymd9-50 is used.

  4. Approve the fix by changing its status to Fixed.

  5. Click Next and when prompted to save the fix, click Yes.

  6. Continue reviewing the selected statements one by one. Notice that each fix for an ADD statement correctly expands the date operands before the statement and contracts the result afterwards.

    Approve each fix by changing its status to Fixed and save each one before going on to the next selected statement.

  7. When you have reviewed, approved and saved all the fixes, click Cancel to return to the worksheet.

The 9 statements you have just fixed have the status Fixed , which means you approved the generated fix without changing it.

There are now 16 green fixed and approved statements and 1 unfixed red statement in the worksheet.

10.11 Removing Statements that Do Not Need Fixing

You have now established the fixes for the statements that need fixing. Before applying the fixes to the source code, you need to remove the statements in the worksheet that have the A-No category, so that they do not automatically get fixed.

  1. Remove the statements that do not need fixing:

    These statements are still in the worksheet, but just moved to the removed list.

  2. To review the removed list:

  3. You can reinstate points of interest from the removed list back into the main worksheet. To experiment with this:

  4. Remove the statement again since it is genuinely not wanted. Notice that the removed count returns to 99.

10.12 Applying the Fixes to the Source

Now that you have established the fixes, you apply the fixes to the new source files.

  1. At the worksheet, click Options and go to the Data and Copybooks tabs for interest only, and notice that you can specify where to put the data declarations for the expanded data items, and how to use copybooks for generated out-of-line fixes. In the Copybooks tab, the default settings add generated data items and out-of-line code to copybooks. Leave the default settings and click OK.

  2. At the worksheet, click Apply Fixes.

  3. Click OK when warned that not all statements have been fixed. This refers to the PERFORM statement with the Not fixed status, which needs a manual fix later.

  4. You can specify individual copybooks and filenames here, to override the defaults if need be. Leave these as they are.

  5. You can change the directory in which to save the fixed sources. By default this is a subdirectory Fixed of the project directory.

  6. Notice at the bottom right, that by default an HTML report, called codegen.htm, is produced on the fixes. This report itemizes the statements that have been fixed and gives details on how they were fixed and includes any errors or warnings.

  7. Start fixing the programs, as follows:

    Select all the programs to fix by clicking Select all. Then click Start and Yes to create the fixed directory.

  8. If you get a message informing you that there were errors or warnings, click OK to the message. Information on the warnings and errors is in the fix report, codegen.htm.

The fixes that you established are now applied to the sources and the new sources saved by default in the Fixed subdirectory. All the statements you fixed had Fixed status of one form or another. If you had had any statements with Auto status, they would also have been fixed.

Also, if you had changed any of the year types in the worksheet after approving the fixes, the new year types would have been used. The only case where the new year types aren't used is in statements where you explicitly set the year type for an individual operand. As long as the year types are being inherited from the worksheet, the latest up-to-date year type is used when you apply the fixes to the source.

Each fix is labelled with a comment, such as:

*SMARTFIX BEGIN FIX #14 (petb, 12/09/1997 14:57:58) *** 

Each comment includes the number assigned to the fix in the worksheet, such as fix number 14 in the example above. To display the fix numbers in the worksheet, go to the Worksheet tab of Options and check Prefix fix number in source.

You might find it useful to produce a Fix status report, at this point, to check the details in each worksheet entry. See the Reports chapter for full details.

You are now ready to go on to compile and test the fixed program. If you anticipate returning to the worksheet and adjusting the fixes, keep the worksheet, project-name.mdb, which is in the project directory, as well as your original sources and the Revolve database, which is also in the project directory.

10.13 Testing the Fixed Program

The demonstration program, redeem.cbl, can operate in a test mode, which builds a test database of contract details and analyzes that database to produce the report. In this mode, run-time parameters are simulated to represent the two-digit year from which to start the analysis, the number of years to report on and the length of each contract in years.

The program runs in test mode by default and requires you to set a start year. As the test data remains the same, the first part of the analysis remains the same whichever start year you set. With the start year set to 91 or earlier, there is no year 2000 problem, but when it is set to 96, 98 or 02, then the unfixed program analyzes the data incorrectly because of various year 2000 problems in the code.

The count of the number of contracts closed within the last six months is calculated with reference to the current date. In order to get this part of the report correct and matching the reference report, you must arrange that the system date is taken to be six years after the start year (for example 23/09/2008 if the start year is 02). This is simple to do using Mainframe Express.

To demonstrate the year 2000 problem in the original redeem.cbl program, compile and run it several times using different start years.

After you have worked through this tutorial, test the fixed program that is generated, or use the supplied fixed program sample\smartfind\redeem\fixed\redeem.cbl. Compile and run the program in a similar way to confirm that it runs correctly for any start year.


Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.
Previous Reporting on the Date Issues Group Worksheet and Administration Next