Creating a COBOL JVM Interface

To create an COBOL JVM interface:

  1. In COBOL Explorer, expand addressBookWrapper > src.
  2. Right-click com.addressBookWrapper.
  3. Click New > COBOL JVM Interface.

    This opens the New COBOL JVM Interface dialog box.

  4. In the Name field, type IWrapper.
    Note: The Source folder and Package fields, will already contain addressBookWrapper/src and com.addressBookWrapper respectively.
  5. Click Finish.

    This opens the IWrapper.cbl program in a COBOL editor.

  6. Rename the existing abstract method from interfaceMethod to openConnection.
  7. Using the same syntax, add the method closeConnection, type the following:
           method-id closeConnection.
           procedure division.
           end method.
    
    Note: Type met and then use Content Assist on the context menu. Alternatively, press Ctrl+Space.
  8. Create methods for creating, updating, and deleting a record using a RecordID and a method to retrieve all records.
    Note: When you declare input and return types you can use either a linkage section as used in the RecordDTO class, or you can declare the type using the as type syntax.

    Your IWrapper.cbl program should look something like this:

           interface-id com.addressBookWrapper.IWrapper public.
    
           method-id openConnection.
           procedure division.
           end method.
    
           method-id closeConnection.
           procedure division.
           end method.
    
           method-id createRecord.
           procedure division returning return-value as type RecordDTO.
           end method.
          
           method-id updateRecord.
           procedure division using by value dto as type RecordDTO.
           end method.
    
           method-id deleteRecord.
           procedure division using by value dto as type RecordDTO.
           end method.
    
           method-id getAllRecords.
           procedure division returning return-value as list[type RecordDTO].
           end method.
    
           method-id maxNumberOfRecords.
           procedure division returning return-value as binary-long.
           end method.
    
           end interface.
  9. Click File > Save.