Click here for HP sponsor message |
Readying COBOL for Year 2000
By Shawn M.
Gordon
The Year 2000 problem has turned into the hottest topic in data
processing in the last year or so, and has caused an
amazing resurgence
of interest in COBOL. The college near my house has dropped
Pascal
and added COBOL in the last year, and its mostly due
to this
situation. All this interest isnt due to COBOLs
inate ability
to deal with dates or the Year 2000. As a matter of fact, there
is no way to declare a date type variable in COBOL. The
interest
lies in the fact that most of the year 2000 code problems
reside
in COBOL code. So my topic this this month is how can you get
4 digit years in COBOL to make your code Year 2000
compliant.
Figure
1 01 FULL-CURRENT-DATE. 03 F-DATE. 05 F-YEAR PIC 9(4). 05 F-MONTH PIC 99. 05 F-DAY PIC 99. 03 F-TIME. 05 C-HOUR PIC 99. 05 C-MINUTES PIC 99. 05 C-SECONDS PIC 99. 05 C-SEC-HUND PIC 99. 03 C-TIME-DIFF. 05 C-GMT-DIR PIC X. 05 C-HOUR PIC 99. 05 C-MINUTES PIC 99.Figure 2 MOVE FUNCTION CURRENT-DATE TO FULL-CURRENT-DATE. DISPLAY 'COBOL CURRENT-DATE [' FULL-CURRENT-DATE ']'. DISPLAY 'COBOL CURR-DATE [' CURRENT-DATE ']'. DISPLAY 'COBOL TIME-OF-DAY [' TIME-OF-DAY ']'. ACCEPT C-DATE FROM DATE. DISPLAY 'COBOL DATE [' C-DATE ']'. ACCEPT C-TIME FROM TIME. DISPLAY 'COBOL TIME [' C-TIME ']'. ACCEPT C-DAY FROM DAY. DISPLAY 'COBOL JULIAN DAY [' C-DAY ']'. ACCEPT C-WEEK FROM DAY-OF-WEEK. DISPLAY 'COBOL DAY-OF-WEEK [' C-WEEK ']'. DISPLAY SPACES. CALL INTRINSIC 'DATELINE' USING DATE-BUFF. DISPLAY 'DATELINE [' DATE-BUFF ']'. CALL INTRINSIC 'CLOCK' GIVING I-TIME. CALL INTRINSIC 'FMTCLOCK' USING I-TIME, Z-TIME. DISPLAY 'CLOCK/FMTCLOCK [' Z-TIME ']'. CALL INTRINSIC 'CALENDAR' GIVING I-CAL. CALL INTRINSIC 'FMTCALENDAR' USING I-CAL, Z-CAL. DISPLAY 'CALENDAR/FMTCAL [' Z-CAL ']'. CALL INTRINSIC 'FMTDATE' USING I-CAL, I-TIME, DATE-BUFF. DISPLAY 'FMTDATE [' DATE-BUFF ']'.Figure 3 COBOL CURRENT-DATE [1997120610342000-0500] COBOL CURR-DATE [12/06/97] COBOL TIME-OF-DAY [07:34:20] COBOL DATE [971206] COBOL TIME [07342090] COBOL JULIAN DAY [97340] COBOL DAY-OF-WEEK [6] DATELINE [SAT, DEC 6, 1997, 7:34 AM] CLOCK/FMTCLOCK [ 7:34 AM] CALENDAR/FMTCAL [SAT, DEC 6, 1997] FMTDATE [SAT, DEC 6, 1997, 7:34 AM] |
||