Inside COBOL #44
by
Shawn Gordon
President
The Kompany

This month we are looking at two totally different topics, but I had room in the column, so what the heck. First the ever vigilant co-chair of SIG*COBOL, Jeanette Nuttsford came across an announcement from the Object Management Group (OMG) regarding the integration of COBOL with CORBA. This is very exciting because CORBA is the common object container that is being used everywhere, and with the new CORBABeans initiative you will be able to access distributed objects
across the network. Very internet kind of stuff. I will let you read for yourself. After the press release I have some COBOL tips for you.

OMG Press Release Announcing COBOL Language Mapping

FOR IMMEDIATE RELEASE
June 23, 1997

Contact: Cheryl Rocheleau
Object Management Group
+1-508-820 4300
rocheleau@omg.org

OMG Continues Enhancement of CORBA Architecture
******************************************
Announces Cobol Language Mapping Specification,

Framingham, MA – The Object Management Group (OMG) announces the adoption
of a COBOL Language Mapping specification for the OMG Interface Definition
Language (OMG IDL) of the Common Object Request Broker Architecture
(CORBA). Additionally, OMG is requesting proposals for a Java to OMG IDL
mapping and for IDL interfaces for access to commonly used Internet services.

About the COBOL Language Mapping Specification
———————————————————————-
The COBOL Language Mapping specification provides the ability to access and
implement CORBA objects within programs written in the COBOL programming
language. The mapping specifies how CORBA objects (objects defined by IDL)
are mapped to COBOL, and how operations of mapped CORBA objects are invoked
from COBOL. The COBOL Language Mapping specification is designed to
facilitate the writing of reliable, well-engineered programs that use an
ORB. Memory management, exception handling, and compile-time type checking
are areas specifically addressed by the mapping.

In accordance with OMG’s policies, all RFP responses were examined by the
ORB Task Force in conjunction with the Architecture Board to ensure
consistency with the Object Management Architecture. The final
specification adopted was submitted jointly by Micro Focus Limited, IBM
Corporation, International Computers Limited, and Siemens Nixorf Information
Systems.

“COBOL is the language in which large-scale mission critical applications
have been developed and continue to be extended. The COBOL language
mapping for CORBA will now enable companies to build upon these substantial
investments by componentizing and re-using business logic as part of a
distributed object environment without incurring the cost of rewriting the
code,” said Jim Sutton, Micro Focus Vice President of Development and
Technology.

About OMG
—————–
With a membership of over 750 software vendors, software developers and end
users, OMG is developing “The Architecture for a Connected World.”
Established in 1989, OMG’s mission is to promote the theory and practice of
object technology for the development of distributed computing systems.
The goal is to provide a common architectural framework for object oriented
applications based on widely available interface specifications. OMG is
headquartered in Framingham, MA, USA and has international marketing
offices in the UK, Germany, Japan, Australia, and India. Additionally, OMG
founded and produces CORBA Academy and sponsors the Object World series of
Trade Shows and Conferences. For information on joining OMG or additional
information, please contact OMG headquarters by phone at +1-508-820 4300,
by fax at +1-508-820 4303, by email at: info@omg.org. OMG provides current
information and services for Distributed Object Computing through The
Information Brokerage on the World Wide Web at: http://www.omg.org.

Note to editors: OMG, Object Management and the OMG logo are registered
trademarks of the Object Management Group. The Information Brokerage,
CORBA, IIOP, OMG Interface Definition Language, CORBAservices,
CORBAfacilities, CORBAmed, and CORBAnet are trademarks of the Object
Management Group. All other products or company names mentioned are used
for identification purposes only, and may be trademarks of their respective
owners.

Recently there was a discussion on the hp-3000 list of how to find a
week number for a given date. More recently Hans van de Spijker made
available this little program to do just that. There is some clever math in here, I always hated doing date math, I would usually do it once and then forget about it. So I hope you enjoy this one.

******************************************************************
* (c)1997 Hans van de Spijker
*
* You have a royalty-free right to use, modify, reproduce and 
* distribute this file (and/or any modified version) in any way
* you find useful, provided that you agree that I have 
* no warranty, obligations or liability for this file.
* 
* Hans van de Spijker
******************************************************************



$CONTROL USLINIT, BOUNDS, DYNAMIC, QUOTE='
$CONTROL POST85
*CONTROL MAP, VERBS
******************************************************************
* This routine calculates the weeknumber from any date
* after January 1, 1601.
* 
* Assuming that:
*   Monday is the first day of the week.
*   January 4 is always in week 1.
*   December 28 is always in the last week of the year.
******************************************************************
 IDENTIFICATION DIVISION.
 PROGRAM-ID.     COBDAT.
 AUTHOR.         Hans van de Spijker
                 A Rozendaelstr 10
                 4931 RE Geertruidenberg
                 The Netherlands
 DATE-WRITTEN.   THU, JUN  19, 1997.
 DATE-COMPILED.
 ENVIRONMENT DIVISION.
 CONFIGURATION SECTION.
 SOURCE-COMPUTER.    HP-3000.
 OBJECT-COMPUTER.    HP-3000.
$PAGE
 DATA DIVISION.
 WORKING-STORAGE SECTION.

 01 MISCELLANEOUS.
    03 WEEK4JAN               PIC S9(9) COMP.
    03 WEEK28DEC              PIC S9(9) COMP.
    03 WEEKNUM                PIC S9(9) COMP.
    03 INT-DATE               PIC 9(8).
    03 DATE-YMD               PIC 9(8).
    03 REDEFINES DATE-YMD.
       05 DATE-YEAR           PIC 9(4).
       05 DATE-MONTH          PIC 9(2).
       05 DATE-DAY            PIC 9(2).

 LINKAGE SECTION.

 01 DATE-YYYYMMDD             PIC 9(8).

 01 DATE-YYYYWW.
    03 WEEK-YEAR              PIC 9(4).
    03 WEEK-NUMBER            PIC 9(2).

$PAGE '**** P R O C E D U R E   D I V I S I O N ****'
 PROCEDURE DIVISION.
 GET-WEEKNUM.
 ENTRY 'GET-WEEKNUM' USING DATE-YYYYMMDD DATE-YYYYWW

     MOVE DATE-YYYYMMDD TO DATE-YMD

     COMPUTE INT-DATE  = FUNCTION INTEGER-OF-DATE(DATE-YMD)
     COMPUTE WEEKNUM = (INT-DATE - 1) / 7

     MOVE 12 TO DATE-MONTH
     MOVE 28 TO DATE-DAY
     COMPUTE INT-DATE = FUNCTION INTEGER-OF-DATE(DATE-YMD)
     COMPUTE WEEK28DEC = (INT-DATE - 1) / 7

     MOVE 1 TO DATE-MONTH
     MOVE 4 TO DATE-DAY
     COMPUTE INT-DATE = FUNCTION INTEGER-OF-DATE(DATE-YMD)
     COMPUTE WEEK4JAN = (INT-DATE - 1) / 7

     EVALUATE TRUE
     WHEN WEEKNUM > WEEK28DEC
       ADD  1 TO DATE-YEAR GIVING WEEK-YEAR
       MOVE 1 TO WEEK-NUMBER
     WHEN WEEKNUM < WEEK4JAN
       SUBTRACT 1 FROM DATE-YEAR
       MOVE DATE-YEAR TO WEEK-YEAR
       COMPUTE INT-DATE = FUNCTION INTEGER-OF-DATE(DATE-YMD)
       COMPUTE WEEK4JAN = (INT-DATE - 1) / 7
       COMPUTE WEEK-NUMBER = WEEKNUM - WEEK4JAN + 1
     WHEN OTHER
       MOVE DATE-YEAR TO WEEK-YEAR
       COMPUTE WEEK-NUMBER = WEEKNUM - WEEK4JAN + 1
     END-EVALUATE
     GOBACK
     .


The calling program would look something like this;

WORKING-STORAGE SECTION.

01 DATE-YYYYMMDD PIC 9(8).
01 DATE-YYYYWW   PIC 9(6).

PROCEDURE DIVISION.
 MOVE 19970711 TO DATE-YYYYMMDD
 CALL 'GET-WEEKNUM' USING DATE-YYYYMMDD DATE-YYYYWW.
 DISPLAY 'DATE ' DATE-YYYYMMDD ' WEEK ' DATE-YYYYWW.

Result

DATE 19970711 WEEK 199726