1

A common technology stack for line of business applications in the sixties and seventies was IBM COBOL with the IMS database. I'm curious about how the combination handled record definitions.

COBOL has a COPYBOOK facility:

00001 * TRAIN6 EXAMPLE COBOL COPYBOOK
00002   01 MASTER_REC.                                                  COL 73-80
00003      05  ACCOUNT_NO                  PIC X(9).                    COL 73-80
00004      05  REC_TYPE                    PIC X.                       COL 73-80
00005      05  AMOUNT                      PIC S9(4)V99 COMP-3.         COL 73-80
...

which seems straightforward enough. Presumably it must also have some equivalent of #include or import so that many COBOL programs can share a single COPYBOOK definition instead of having to repeat it.

IMS must also have had a record definition facility, and indeed there is an example of usage in https://share.confex.com/share/125/webprogram/Handout/Session17764/SHARE_Orlando%20DDL%2017764.pdf

CREATE TABLE table_decimal (
    r_number INT INTERNALNAME RNUM,
    ll SHORT INTERNALNAME LL,
    c_decimal DECIMAL(7,2) INTERNALNAME CDEC,
    FOREIGN KEY REFERENCES table_root
) IN COGDBD.COGDATA
    INTERNALNAME TDEC
    MAXBYTES 10
    MINBYTES 6
    INSERT LOGICAL
    DELETE LOGICAL
    REPLACE LOGICAL
    AMBIGUOUS INSERT HERE;

There is some syntax overlap with SQL. I'm not sure whether that's because IMS DDL is an ancestor of SQL, or because some of the latter was retrofitted to a later version of the former.

But how was the combination handled?

If a COBOL program tried to read an IMS table, but the two were using different record definitions, would there be a runtime check for metadata compatibility, and a crash with an error message? Or would the COBOL program just misinterpret the stream of bytes, giving garbage results?

And how was maintenance handled? Did programmers have to keep the COBOL and IMS record definitions in sync by hand, or was there an automatic way to generate one from the other, or both from some third format?

7
  • Serious, this is way to broad to be answered in a useful manner. In general, COBOL doesn't have 'Streams of bytes' but records, which are blocks of defined length and handled as such. COBOL does not care about table definitions or whatever it has records. It reads records and writes records. If some fancy database splits them into tables or whatever that's none of COBOLs concern.
    – Raffzahn
    Nov 27 '20 at 18:46
  • @Raffzahn My question is most certainly not broad, whatever else it may be; if it looks that way, then perhaps it is unclear. The rest of your comment suggests so, because you remark that COBOL has records as though this were news, when my entire question is about COBOL and records! But a COBOL program often reads its records from a database. Does anything check that the program and database are using consistent record layout definitions? If so, what software layer does this check?
    – rwallace
    Nov 27 '20 at 19:02
  • The question,as it isworded, takes on the whole process of data access from cobol, als well as database interfaces and design. I'd say that' rather broad.| Your comment makes it even more clear that you assume more about records and their handling than there is. A record is only a definition of a memory area. It gets turned into a DSECT when compiled, to deliver offset and length to machine operations. There is nothing else, especially nothing about data base definitions, connections or checks thereof. This may happen in some module linked in, but is not part of the (basic) Language.
    – Raffzahn
    Nov 27 '20 at 19:16
  • 2
    Doesn't the createdatamaps utility, which your COPYBOOK came from, do exactly what you are asking about? Read the Utility Overview link. Back in the days when the turnround time for a computer run was hours not seconds, the standard way to avoid these type of errors was desk checking printouts, not using software tools.
    – alephzero
    Nov 27 '20 at 20:13
  • 1
    COPYBOOK is the #include, no? That’s what we always used it for.
    – RonJohn
    Nov 28 '20 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.