home about us   contact us
 
   







 


Chicago-Soft
ATTN: TSO Times
One Maple Street
Hanover, NH 03755
(603) 643-4002
information
@tsotimes.com

 

Y2K Issue: Coping with the dreaded gregorian-to-julian subprograms

by David Shelby Kirk

If you've been on a Y2K project, you've probably already encountered one of those dreaded subprograms that convert gregorian-to-julian or julian-to-gregorian. Often, they totally ignore the century issue and making them work correctly can be challenging. Well, there's an easier way to solve this problem than in modifying that old code. Just use the intrinsic functions in COBOL for MVS (or OS/390.)

Earlier intrinsic functions:
For background information, when IBM first introduced this new family of COBOL, the language name was COBOL/370 (now changed with the later version to COBOL for MVS.) In that first edition, IBM introduced intrinsic functions, four of which are of special interest in a Y2K project. At the time, there was little thought of them. They are INTEGER-OF-DAY, INTEGER-OF-DATE, DAY-OF-INTEGER and DATE-OF-INTEGER. These four functions convert a julian or gregorian date into a non-date integer, allowing easy conversions between the two formats.
For example:

compute field-i = function integer-of-day (julian-data-field)
compute field-g = function date-of-integer (field-i)

converts a julian date element into an integer, stores it in field-i and the next statement converts the integer into a gregorian date element, being stored in field-g.

Newer Y2K intrinsic functions:
Early in 1998 IBM introduced some Y2K intrinsic functions to COBOL for MVS. These new functions provided windowing capabilities to ease the conversion of julian and gregorian dates with 2-digit years into 4-digit years. A discussion of those functions would be a separate article.

Mixing both sets of intrinsic functions:
Now, in drawing the functions together is where the true power of these intrinsic functions shine. The new functions are able to convert a date element with a 2-digit year into one with a 4-digit year. If we combine that power with the earlier functions' ability to convert from one format to another, we can eliminate the need for a conversion subprogram - and the need to remedial any existing ones. Also, the variable for a function can be the output of another function. So, we can nest them together. Let's do it in this example:

Original code, prior to conversion:

call 'gregjul' using date-field-j, date-field-g

where the routine is to convert a date element from date-field-j into date-field-g). Instead of converting the 'gregjul' subprogram to be Y2K-compliant, we can eliminate it and use one compute statement that nests 3 intrinsic functions: one to create a Y2K date, one to convert the date element to an integer, and one to convert the integer to the desired date format.

Here is that example:

compute date-field-g = function date-of-integer
(function integer-of-day
(function day-to-yyyyddd (date-field-a)))

Note: To keep the article abbreviated, I did not show the PIC clauses for the data elements. Those should be whatever length the application requires. For example, many windowed applications retained their 2-digit year data fields, using the windowing technique for logic control. That approach would work here as well.

About the Author:
David Shelby Kirk, an outstanding expert in the field, is an instructor, author, and a successful consultant with MVS Training, Inc. His newest book COBOL for OS/390 Power Programming with Complete Year 2000 Section is now available to own. Call (800) 356-9093 or contact dkirk@mvs-training.com to order.

MVS Training, Inc. helps clients optimize their people's programming and systems administration skills by providing state-of-the art mainframe training tailored to the client's work environment and their information technology personnel's needs. Specialists in COBOL, NEW OFFERINGS include public workshops, and book publications. For more information contact: (800) 356-9093, sales@mvs-training.com or www.mvs-training.com.



The TSO Times is back by popular demand!
Register now for your FREE subscription









 

Chicago-Soft, LTD
ISPF Tools & Toys
MVS Help Board
Lionel Dyck's Tools
IBM ISPF Page
Tom Brennan's Vista tn3270 Page
Mark Zelden's MVS Utilities


 


 

home · current articles · archives · forums ·
· subscribe · about us · contact us · links