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?

8
  • 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
    Commented Nov 27, 2020 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
    Commented Nov 27, 2020 at 19:02
  • 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
    Commented Nov 27, 2020 at 20:13
  • 1
    COPYBOOK is the #include, no? That’s what we always used it for.
    – RonJohn
    Commented Nov 28, 2020 at 0:57
  • 1
    Regarding your comment "Presumably it must also have some equivalent of #include or import" to use copybooks, I think you'll find that was the COBOL COPY statement. That is, after all, where the copybook gets its name from :-)
    – paxdiablo
    Commented Mar 29, 2022 at 8:42

0

You must log in to answer this question.

Browse other questions tagged .