Using COPY RESOURCE

If you are creating a simple, single object library without ".xfd" files, you can use the COPY RESOURCE statement to package your applications, bitmaps, and configuration file instead of or in addition to the cblutil utility.

Use the COPY RESOURCE statement as follows:

COPY RESOURCE resource-name [ {IN} path-name ] .
                              {OF}

where resource-name and path-name identify a resource file to be included in the resulting object file.

The effect of a COPY RESOURCE statement is to add resource-name to a list of resources that the compiler embeds into the resulting COBOL object file. The resources are added to the end of the COBOL object in the same order as the corresponding COPY statements. Since the resources are added to the end of the object, the location of the corresponding COPY RESOURCE statement in the COBOL program is irrelevant. Conventionally, COPY RESOURCE statements are placed either in Working-Storage or at the end of the program, but any location is acceptable.

If resource-name resolves to a COBOL object or library file, the compiler includes this object or library in the resulting object in a manner similar to cblutil -lib. These are not considered resources, but are embedded COBOL objects.

If you are creating a library containing multiple COBOL objects, we recommend using cblutil -lib instead of using COPY RESOURCE. Using cblutil, you do not need to worry about the order in which COBOL objects are compiled (if you use COPY RESOURCE, you must ensure that the copied object is compiled first), and cblutil also checks for duplicated program names while COPY RESOURCE does not.

Although technically you can include .xfd files in a library using COPY RESOURCE, these files must exist before you compile with the COPY RESOURCE statement. Because .xfd files are created at compile time, this means you must compile more than once. For this reason, the cblutil method is also preferred for including .xfd files in your object library.