Define MakeCheckAppt Operations

Provides step-by-step instructions that guide you through the process of defining four operations for the MakeCheckAppt service interface.
Restriction: This topic applies only when the Enterprise Server feature is enabled.

Each service interface you create is comprised of a set of operations. In this section of the tutorial, you create one operation for each of the two functions provided by the application.

Tip: As you define these operations, we recommend that you save your work periodically. You can do this at any point you choose and as often as you like by clicking File > Save MakeCheckAppt.svi from the Visual Studio menu.
Note: By default, Visual COBOL creates REST operations that use the HTTP POST method, which enables the sending of a REST request.

MakeAppt Operation

The purpose of the MakeAppt operation is to create an appointment and store it in the system.

Create the MakeAppt Operation
  1. From the main menu, click Operation > New.
  2. In the Name field, type MakeAppt.

    This application contains only one program, schedule.cbl, which appears on the Select program/copybook list.

  3. From the Select program/copybook list, select schedule.

    The name of each entry point contained in the program appears farther down on the dialog box.

  4. From the Select entry point list, select SCHEDULE. The entry point code appears to its right.
  5. Click OK.

In the Interface Mapper, you now see that the entry point fields have been placed into the COBOL Entry Point pane on the left.

Define Interface Fields
The Schedule program needs several input items to create an appointment, including variable information such as the customer's name, the identification number of the consultant with whom the appointment is to be made, the date of the proposed appointment, and the desired time slot. You define interface fields to hold this information so that the client can send it to the application.
  1. Drag the following fields from the COBOL Entry Point pane to the Interface Fields pane:
    • lnk-customer-name
    • lnk-consultant-id
    • lnk-yyyy
    • lnk-mm
    • lnk-dd
    • lnk-time-slot

    This creates interface field names similar to those of the entry point fields from which they were created. The difference is that all dashes (-) are automatically replaced with underscores (_). In addition, a mapping is automatically created between each new interface field and its corresponding entry point field.

    The purpose of the lnk_customer_name, lnk_consultant_id, lnk_yyyy, lnk_mm, lnk_ddand lnk_time_slot fields are to hold data that is sent to the application for processing; therefore, they are input fields. The default mapping direction for each of these, Input, is correct.

    Because this is a JSON service, all fields of the same direction must share a structure to represent the root object in the JSON request or response. Currently, this operation has multiple input fields; therefore those fields must be put into a group.

  2. Select all the fields in the Interface Fields pane; then right-click and select Group.
  3. On the Group Properties dialog box, type root_in into the Name field, and then click OK.
    Note: The default values for Occurs (0), Direction (Input), and Location (Body) are correct.

    Once the Schedule program receives the input information from the client, it sends back a code to indicate whether or not the requested appointment is available. The program field that receives this code is lnk-op-ok. Therefore, you need to create a corresponding interface field, and change its mapping direction from Input (default) to Output.

  4. Drag the lnk-op-ok field from the COBOL Entry Point pane to the Interface Fields pane.
  5. In the Direction column for the lnk_op_ok interface field, double-click Input and use the drop-down list to change the direction of the field to Output.
Define COBOL Assignments
Because the MakeAppt operation executes only one program function, the value required to initialize that function remains constant. In this case, you create a COBOL Assignment field rather than an interface field, and assign it the value required by the program to ensure the execution of the specific function.

From looking at the program source code, you know that when the value in the lnk-operation field is 0, the program executes the set-appt code. Therefore, you want to assign the lnk-operation field a value of 0.

  1. Drag the lnk-operation field from the COBOL Entry Point pane to the COBOL Assignments pane.
  2. In the Value field, type 0; then click OK.

    For this particular service, you want to make appointments only for one specific store. When the Schedule program executes, it reads the value in the lnk-id field to identify the store where the appointment is to be made. Therefore, you can provide the same store identification number each time the service runs by assigning a constant value.

  3. In the COBOL Entry Point pane, expand the lnk-store-info group.
  4. Drag the lnk-id field from the COBOL Entry Point pane to the COBOL Assignments pane.
  5. In the Value field, type 08780; then click OK.
  6. Click File > Save MakeCheckAppt.svi to save the service interface.
Completed MakeAppt Operation

MakeAppt Operation

CheckAppt Operation

The purpose of the CheckAppt operation is to look up an existing appointment and return its details.

Create the CheckAppt Operation
  1. From the main menu, click Operation > New.
  2. In the Name field, type CheckAppt.

    The Select program/copybook list shows only the schedule program, which is already selected for you. This is because each service interface can use only one program, and you specified the schedule program in the MakeAppt operation you defined earlier for this same service interface.

  3. From the Select entry point list, select SCHEDULE. The entry point code appears to its right.
  4. Click OK.

In the Interface Mapper, the entry point fields once again appear in the COBOL Entry Point pane on the left.

Define Interface Fields
The CheckAppt operation uses most of the same interface fields as does the MakeAppt operation, and in addition includes an output array in which the queried appointment appears, if found. Follow these steps:
  1. Drag the following fields from the COBOL Entry Point pane to the Interface Fields pane:
    • lnk-customer-name
    • lnk-consultant-id
    • lnk-yyyy
    • lnk-mm
    • lnk-dd

    Because there are multiple input fields, they must be grouped to represent the JSON request structures.

  2. Select all fields in the Interface Fields pane, right-click, and then select Group from the context menu.
  3. On the Group Properties dialog box, type root_in into the Name field, and then click OK.
    Note: The default values for Occurs (0), Direction (Input), and Location (Body) are correct.
  4. Drag the lnk-op-ok field from the COBOL Entry Point pane to the Interface Fields pane.
  5. In the COBOL Entry Point pane, expand the lnk-day group.
  6. Drag the lnk-cust-id field to the Interface Fields pane.

    Because both lnk_op_ok and lnk_cust_id need to be output fields, you need to group them and change their direction to represent the JSON response structures.

  7. In the Interface Fields pane, select the lnk_op_ok and lnk_cust_id fields, right-click, and then select Group from the context menu.
  8. On the Group Properties dialog box, type root_out into the Name field.
  9. Select Output, and then click OK.
    Note: The default values for Occurs (0) and Location (Body) are correct.
Define COBOL Assignments
The CheckAppt operation needs to execute the read-appt application code. Therefore, you need to assign the lnk-operation field a value of 1.
  1. Drag the lnk-operation field from the COBOL Entry Point pane to the COBOL Assignments pane.
  2. In the Value field, type 1; then click OK.

    Just as you did for the MakeAppt operation, you want to assign a constant value for the lnk-id field so you are sure to query the same store each time.

  3. In the COBOL Entry Point pane, expand the lnk-store-info group.
  4. Drag the lnk-id field from the COBOL Entry Point pane to the COBOL Assignments pane.
  5. In the Value field, type 08780; then click OK.
  6. Click File > Save MakeCheckAppt.svi to save the service interface.
  7. Close the Interface Mapper.
The Completed CheckAppt Operation

CheckAppt Operation