Language Environment Services Used

Three LE services are used in this sample COBOL program: CEE3ABD, CEEGTST and CEECZST. Service CEE3ABD is the LE’s abnormal end (ABEND) callable service. It’s called only if the input file fails to open properly. Use CEE3ABD to force an ABEND for whatever condition you want.

The other two LE services comprise the heart of this LE COBOL example. CEEGTST is the service call that performs a straightforward memory acquisition much like a GETMAIN:

Call Le-Getstg Using Heap-Id-0 Storage-Len Storage-Adr Omitted

For example:

• The Call identifier-1 format is used to ensure a dynamic invocation of CEEGTST.
• Heap-Id-0 tells CEEGTST to acquire the storage from the user heap—the same heap where all the other storage for the program is acquired.
• The length of the storage to be acquired is determined by using the COBOL special register Length Of:

Move Length Of Overflow-Table To Storage-Len

• The address of the acquired storage is returned in the field named Storage-Adr, a pointer data item.
• By coding the Omitted COBOL keyword as the final passed parameter, the LE Feedback area is being omitted. This will allow CEEGTST to ABEND if it can’t acquire the storage being requested.

The CEECZST service is a bit more complex. The service it performs is acquiring additional storage for an already existing piece of storage that was acquired by CEEGTST or CEECZST. Think of CEECZST as the change size (CZ) storage service.

CEECZST requires a starting address. As mentioned earlier, the techniques used in this sample COBOL program are open-ended with respect to the number of overflow entries for a given table. However, to pull this off, it’s mandatory that the latest address of either the first piece of CEEGTST acquired storage or the latest piece of acquired storage resized by CEESZST is saved somewhere. The following statement in the COBOL program is executed after both the CEECZST and the CEEGTST. It accomplishes this address save:

Set Start-Overflow-Pointer To Storage-Adr

The field named Start-Overflow-Pointer is, of course, a pointer data item. Note that native COBOL syntax allows a pointer data item to be set to the value of another pointer item by using the Set statement.

The trick to understanding how the CEECZST service functions is to read the LE documentation for the service. Particularly, this portion of the explanation:

The CEECZST service returns a pointer to the reallocated heap element. It can move the storage location of the heap element. As a result, the address parameter passed to CEECZST is not necessarily the same as the value returned.

4 Pages