getting started with OO and method calls

[Migrated content. Thread originally posted on 23 October 2011]

I am an experienced COBOL programmer looking to move to a project using OO cobol and doing a little self education.
I have a pretty good grasp of JAVA and C# so was expecting to pick it up reasonably easily. It will be syntax and basic program/class structure I need to get to grips with.

My first attempt at a COBOL JVM project using visual COBOL for eclipse.
I am getting error "COBCH0829S could not find method "storeData" with this signature".

Any guidance on where to look for and how to fix it would be appreciated.


class-id Learning1.

data division.
working-storage section.
01 classField pic x(1).

procedure division.
method-id storeData.

working-storage section.
linkage section.
01 methodField pic x(10).
procedure division using methodField.
move methodField to classField
end method.

method-id. returnData.
working-storage section.
linkage section.
01 methodField pic x(10).
procedure division returning methodField.
move classField to methodField
end method.

end class-object.

program-id Learning2.


Learning1 IS CLASS "Learning1".


working-storage section.
01 myLearning usage object reference.
01 passField pic x(10) value low-values.


INVOKE Learning1 "NEW" returning myLearning
INVOKE myLearning "storeData" using passField


COBCH0829S could not find method "storeData" with this signature

  • Verified Answer

    Hi Gary. Looking at your program, the compile error you're getting is caused by declaring learning1 as object reference instead of type Learning. Have a look at the COBOL JVM samples included with Visual COBOL to see how the syntax has evolved to make writing OO code easier.
  • Thanks for the response Paul.
    That helped, I have fixed it now.
  • Hi Paul,
    even though I fixed the problem, where do I find the example code for COBOL JVM classes? In particular I am looking for an explanation of syntax for nesting classes ie. equivalent to COBOL occurs array containing multiple (same type) classes.

    Appears I have fixed my problem by prefixing the class name with the package name (I had been using the default package previously). Is it necessary to add the prefix or is there an option somewhere to control this?

    Thanks for your time,
  • The demonstration programs are installed in subfolders under C:\Users\Public\Documents\Micro Focus\Visual COBOL 2010\Samples.

    Note: On older versions of Windows the samples might be installed in a different folder, such as for Windows XP, C:\Documents and Settings\All Users\Documents\Micro Focus\Visual COBOL 2010\Samples.

    To access the demonstrations:

    Click Start menu > All Programs > Micro Focus Visual COBOL 2010 > Visual COBOL Samples.
    This opens the Samples Browser form.

    Select a sample in the central pane and click Open sample folder.
    Open the sample in Eclipse.
  • Thanks Chris,
    I followed that path. I am getting "Readme Not Found!" in the bottom panel and nothing is clickable.

    Thanks for your assistance,
  • You might want to open up a Support Incident with Customer Care for this as I am not experiencing the same problem.
    Are you using the Visual COBOL R4 release for Eclipse?

    The Readme files are located in the project folders for the various samples for example:

    C:\Users\Public\Documents\Micro Focus\Visual COBOL 2010\Samples\Eclipse\jvm_cobol\Arrays\readme.xml

    The following are the instructions for importing the various samples into an Eclipse Workspace so they can be used.

    Importing the Project into Eclipse

    First you have to import the Demonstration project into your Eclipse workspace.

    Select File -> Import. The Import | Select dialog box opens.
    Select General -> Existing Projects into Workspace, then Next. The Import | Import Projects dialog box opens.
    Select the Select root directory radio button, then Browse. The Browse for Folder dialog box opens.
    Navigate to the samples folder.
    Select the demonstration project(s) in the Projects list in Import | Projects.
    Select Copy projects into workspace
    Select Finish.

    Now the Demonstration project(s) should be displayed in the Navigator window.

  • Thanks Chris, I have sorted it out. Somehow one of my folders had been renamed (I'm not the only user on my PC).

    Sorry for the delayed reply, I have just got back to learning again.

  • Not a problem Gary, thanks for the update...