Initiating Interactive Processes from COBOL

A COBOL program initiated from a MARC or CANDE session inherits the STATION task attribute of the session. The STATION attribute, in turn, is inherited by any processes initiated by the COBOL program. As a result, these processes can usually open a remote file at the originating terminal without having to make any special remote file assignments.

However, remote file opens can fail because the STATION attributes stores the logical station number (LSN), which is subject to change. To prevent this problem, you can include statements such as the following in the COBOL program:

MOVE ATTRIBUTE SOURCENAME OF MYSELF TO NAMEBUF.
CHANGE ATTRIBUTE STATIONNAME OF MYSELF TO NAMEBUF.

The preceding statement assigns the originating station name to the STATIONNAME task attribute, which in turn is inherited by all tasks. These statements assume that NAMEBUF was declared as

01 NAMEBUF PIC X(80)

A COBOL program initiated from a WFL job or from an ODT might not inherit a STATION or STATIONNAME value. For further information, refer to Work Flow Language (WFL) earlier in this section and to Communicating with an ODT in Tasking from Interactive Sources.