A simple COBOL application on a remote system

This sample guides you through the process of building, and running a simple COBOL application on a remote system. The sample contains two simple COBOL files. The programs request input through a command-line interface and writes back a response.

This sample leads you through the following tasks:
  • Create a remote project from a sample shipped with Developer for z/OS®
  • Allocate a partitioned data set, create a z/OS project
  • Build executable code from COBOL source
  • Run an application on the remote system
Note: This sample requires a connection to the host system.
Make sure that the z/OS Build and Remote System Explorer servers are configured and started. You also need a connection to the z/OS host system defined in your workspace. To create the connection, the following connection information is needed from your system administrator.
  • The name or TCP/IP address of the host system.
  • The port number for the connection.
  • The method used in your environment to launch the server and information. The information that is needed is different based on the method. See Connecting to a z/OS system for the specific information needed and instructions on creating a host connection

Import the sample code

Before you begin

Make sure that the z/OS Build and Remote System Explorer servers are configured and started and you are connected to the host system.

About this task

Before you can copy the sample application code, a partition data set must be allocated on the host system. The five partition data sets needed for this sample are listed in Table 1. The table also contains the information to allocate each partition data set.
Table 1. Partition data sets needed for the sample
Data set name Category Type
<HLQ>.REMOTE.COBOL SOURCE COBOL
<HLQ>.COBOL.OUTPUT* LISTING COBOL
<HLQ>.COBOL.SYSDEBUG* LISTING COBOL
<HLQ>.COBOBJS.OBJ* SOURCE COBOL
<HLQ>.COBOL.COPYLIB* SOURCE COBOL
Note: The data sets marked with an asterisk (*) are required by the COBOL step of the ELAXFCOC procedure described in a later step. The data set names must match the data set names referred to in the COBOL step options.

Procedure

  1. Complete the following steps for each of the data sets listed in Table 1 to allocate the partition data sets.
    The <HLQ> variable represents the user ID that you used to log on to the host system. You do not need to change this variable when allocating the partition data set.
    1. In the Remote System view, right-mouse click MVS Files and click New > Allocate Partitioned Data Set.
    2. On the Allocate Partitioned Data Set page, complete the Data Set Name field.
      There are two parts to the data set name.
      • The first part is the high-level qualifier. Use the drop-down menu to select a predefined name or type in a name. The predefined name is the user ID used to log on to the host system.
      • The second part is the data set name. Use the names defined in the table.
      For example, for the first data set in the table, the value for the Data Set Name could look like MYFILES.REMOTE.COBOL where MYFILES is the high-level qualifier.
    3. Click Next.
    4. On the Data Set Allocation page, select Specify characteristics by usage type and then select the corresponding value for each field as shown in the table.
    5. Click Finish.
    After you create all the partition data sets, you should see them listed under MVS files in the Remote System view.
    List of partition data sets in the Remote System view
    The sample data can now be moved to the host system.
  2. From the workbench, click File > New > Example.
  3. Expand Workstation COBOL and click COBOL Sample 1 > Next.
  4. On the z/OS Local Project window, type LocalCOBOLSample in the Project name field and click Finish.
    The data is now in a local project on your computer.
  5. Copy the COBOL source files, PrintApp.cbl and StartApp.cbl, to the <HLQ>.REMOTE.COBOL partitioned data set. You can copy and paste or drag the files from the Local Project view to the Remote System view.

Work with the sample code

About this task

You are now ready to create the z/OS Project and MVS subproject, create a property group, and set the build options.

Procedure

  1. From the Developer for z/OS workspace File menu, click New > Other.
  2. Expand z/OS Development and select z/OS Project and click Next.
  3. On the z/OS Project Name window, type SampleProject in the Project name field and select Create an MVS subproject. Click Finish.
  4. On the MVS Subproject Name and Location window, complete the following fields and then click Finish.
    SubProject Name
    Type RemoteCOBOLSample.
    High-level Qualifier
    Use the default value which is the user ID with which you logged on to the remote system.
    Property Group
    Click Create a property group and associate it with the subproject. Specify a property group name in the name field and click Finish.
  5. The Property Group Editor opens and you can define the build options for the new property group:
    1. Click the COBOL tab and then click Procedures and Steps.
    2. Expand the ELAXFCOC procedure and double-click COBOL to edit the COBOL step. Make sure your specified data set names were created or replace them with existing ones.
    3. Click the Link tab and then click Procedures and Steps.
    4. Expand the ELAXFLNK procedure and double-click LINK to edit the LINK step. Make sure the Load module location data set has been created, or replace the data set with an existing one.
    5. Click the Run tab and expand the ELAXFG0 procedure. Copy and paste the following JCL into the Additional JCL text box.
      //SYSOUT DD SYSOUT=*
      //SYSPRINT DD SYSOUT=*
      //SYSIN DD *
        Ben
        Q
      /*
      //
    6. Click the JCL tab in the property group editor. Verify that the default JOB card includes a PROCS statement and that the PROCS statement points to the procedure library on the remote system.
      If you do not know the location of the procedure library, ask your system administrator.
    7. Close and save the new property group.
  6. Add the <HLQ>.REMOTE.COBOL partitioned data set to the RemoteCOBOLSample subproject:
    1. Select the data set in the Remote Systems view.
    2. Right-click and select Add to Subproject.
    3. Type or select the subproject name and click Finish.
    You can now build and run the application on the remote system.
  7. In the RemoteCOBOLSample subproject, right-mouse click STARTAPP.cbl and click Nominate as Entry Point.
  8. Right-mouse click RemoteCOBOLSample and then click Rebuild Subproject.
  9. Select the generated load module, and click Run > Run to run the application.