Reporting on the Date Issues | Group Worksheet and Administration |
This tutorial in this chapter demonstrates how to fix the the year 2000 problems in the sample application.
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.
This section explains how to open the appropriate worksheet for the Tour project.
Set fix mode as follows:
All the fixing options on all the worksheet tabs are now enabled, so that you can customize the way to generate fixes.
Click OK.
The worksheet shows 17 filtered statements.
The worksheet should contain 53 data items and 119 statements.
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:
Depending on how you have Windows set up, the worksheet names are displayed with or without the .mdb extension.
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.
The worksheet contains 53 data items and 119 statements.
This section describes the fix that is automatically generated for one of the SUBTRACT statements.
subtract p-start-year
. To see the
line numbers, widen the Location column by dragging its heading.
p-start-year
is treated:
p-start-year
in the worksheet. This means
the operand is fixed using the macros for the YY9 year type.
sf2k-p-start-year
.
rd-end-yy
is fixed in
essentially the same way as p-start-year
.
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.
*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.
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.
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.
ADD
P-START-YEAR
.
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.
tmp-end-yy
in the operand table at
the top right, as follows:
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.
This section shows another fix that SmartFix automatically generates and how you can edit the generated code to suit the program being fixed.
ADD 1900
P-START-YEAR
.
p-start-year
,
and then goes on to add 1900, which is not what the original statement
intended.
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.
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.
This section shows how the header of a PERFORM statement is fixed.
PERFORM VARYING TMP-YY
.
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.
tmp-yy
is treated:
tmp-yy
is
expanded before the statement. In this case, this expansion is
superfluous, since the PERFORM statement immediately overwrites the
value of sf2k-tmp-yy
with the value of sf2k-p-start-year
.
However, in some cases this expansion is required and so it is
included for completeness. Leave the expansion intact, since it does
no harm.
sf2k-tmp-yy
is
contracted back to a two-digit year after the PERFORM statement
header. This is needed because the two-digit version is used in the
subsequent performed code.
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
.
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
.
*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
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.
In this section you fix the COMPUTE statements.
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.
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.
COMPUTE
SUB2
. Set the year type for SUB2
to YY9 and click
Save when you have finished.
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.
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.
PERFORM
READ-CONTRACT-FILE
.
The unfixed PERFORM statement is now shown in red.
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.
In this section, you work through the remaining statements in turn, examining the generated fixes and approving them.
To do this, sort the statements first into statement order and second into status order and then select the statements with Auto status.
sf2k-expand-yy9-50
or sf2k-expand-ymd9-50
is
used.
Approve each fix by changing its status to Fixed and save each one before going on to the next selected statement.
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.
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.
These statements are still in the worksheet, but just moved to the removed list.
Now that you have established the fixes, you apply the fixes to the new source files.
Select all the programs to fix by clicking Select all. Then click Start and Yes to create the fixed directory.
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.
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.
Reporting on the Date Issues | Group Worksheet and Administration |