University of Michigan

Medical Center Information Technology

COBOL II ACCEPT DATE Coding

 

We are currently using the IBM COBOL II compiler for most of our mainframe programs. The release that we are using is NOT compliant for the year 2000 and beyond. ‘Not compliant’ means that when the date is requested via the ACCEPT verb, the value returned does not include the century. The six digit returned value is in the format YYMMDD where YY is the low order two digits of the year, MM is the month and DD is the day of the month. The COBOL/MVS and COBOL/390 compilers handle the date in the format CCYYMMDD, but we do not have either of these compilers available yet. Since we don’t have a compliant COBOL compiler, we should take steps to code any new programs, and modify any existing programs to emulate the eight digit date. The emulation is simple and, if done correctly, will allow COBOL programs to be recompiled with the compliant compilers WITHOUT source code modifications. The key to correct coding is knowing the behavior of the ACCEPT ‘variable’ FROM DATE statement. Accepting the date into an eight byte numeric display field, that has been initialized to zeros, causes the six byte date to be placed in the low order six bytes of the receiving field without alteration of the high order two bytes. By the use of REDEFINES or REFERENCE MODIFICATION, a test of the high order two bytes can determine whether the compiler used was compliant or not and the century value can then be set programmatically if necessary. The call to the McKesson/HBOC subroutine KUDTEXA will perform the windowing technique adopted at the University of Michigan which requires that any two digit year valued from 00 through 24 is to have a century value of 20 and the years 25 through 99 to have 19 as their century value. The use of the subroutine call is recommended, as opposed to coding the windowing in the program, to minimize the impact if the window is changed. The attached sample COBOL code segments illustrate the method of emulating the COBOL/MVS and COBOL/390 compilers using the REDEFINES technique.

Working Storage code:

          01  KUCOMCC.
              COPY KUCOMCC.
          01  RUN-DATE-TIME-AREA.                                              
              02  RUN-DATE               PIC 9(08) VALUE 0.                    
              02  RUN-DATE-BREAK REDEFINES RUN-DATE.                           
              03  RUN-CENTURY        PIC 9(02).                               
                  03  RUN-YEAR           PIC 9(02).                           
                  03  RUN-MONTH          PIC 9(02).                           
                  03  RUN-DAY            PIC 9(02).                           
              02  RUN-TIME               PIC 9(08).                           
              02  RUN-TIME-BREAK REDEFINES RUN-TIME.                          
                  03  RUN-HOURS          PIC 9(2).                            
                  03  RUN-MINUTES        PIC 9(2).                            
                  03  RUN-SECONDS        PIC 9(2).                            
                  03  RUN-CENTI-SECONDS  PIC 9(2).                            

Procedure Division code:

* *------------------------------* * * OBTAIN CURRENT DATE AND TIME * * *------------------------------* ACCEPT RUN-DATE FROM DATE. ACCEPT RUN-TIME FROM TIME. * *---------------* * * MILLENIUM FIX * * *---------------* IF RUN-CENTURY = ZERO MOVE ‘G6C’ TO COMM-DATE-PARMS MOVE RUN-MONTH TO COMM-DATE-GREG (1:2) MOVE RUN-DAY TO COMM-DATE-GREG (3:2) MOVE RUN-YEAR TO COMM-DATE-GREG (5:2) CALL ‘KUDTEXA’ USING KUCOMMCC MOVE COMM-DATE-GREG-INVERTED (1:8) TO RUN-DATE END-IF.