z/OS Language Environment Writing Interlanguage Communication Applications
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Sharing files between COBOL and PL/I

z/OS Language Environment Writing Interlanguage Communication Applications
SA38-0684-00

By specifying the COBOL option in the PL/I ENVIRONMENT attributes in a file declaration, files can be shared between COBOL and PL/I. However, if structures are used in a file, mapping can be different, as described in Using aggregates. When structures are in a file and you don't know whether the mapping is the same, both COBOL and PL/I structures are mapped. Then the object module transfers the data between structures immediately after reading the data for input and immediately before writing the data for output.

During compilation, the compiler examines the record variable to see if there are any structures. If there are no structures, no further action is taken. If there are structures, the compiler tests to see if the mapping of the structure(s) is the same in PL/I and COBOL. If the mapping is the same, no action is required. If the compiler cannot determine that the mapping is the same, or if the structure is adjustable, both structures will be mapped.

When the compiler reformats the data, and when a record I/O statement involving a file with the COBOL option is executed, the following actions take place:
INPUT
The data is read into a structure that has been mapped using the COBOL mapping algorithm and assigned to a PL/I mapped structure.
OUTPUT
Before the output takes place, the data in the PL/I structure is assigned to a structure mapped for COBOL. The output to the file then takes place from the second structure.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014