Absent Member.
Absent Member.

Receiving Java custom record in procedural cobol


We want to share a Cobol Structure between our Cobol program and a new Java Program.

The Cobol program will call the Java program.

We have succeeded running simple examples exchanging simple data type beteen Cobol and Java. We have failed so far with the CustomRecord data type.

Here is our Java CustomRecord class:

import com.microfocus.cobol.lang.*;

public class TPrestInter implements CustomRecord, java.io.Serializable {

private static final long serialVersionUID = 827363353239593196L;
private long noEmployeur;

public Object[] getParameters(){
return new ParameterList()

public void setParameters(Object[] params) {
Byte[] byteNumeroEmployeur = (byte[]) params[0]);
setNoEmployeur (Integer.parseInt(new String(byteNumeroEmployeur));

public Long getNoEmployeur() {
return this.noEmployeur;

public void setNoEmployeur(Long noEmployeur) {
this.noEmployeur = noEmployeur;

Here is the Java class That generates custom record objects

public class LireTPrestInt {

public TPrestInter getObject(){
TPrestInter object = new TPrestInter();
return object;

Here is the Cobol program

$set ooctrl(+p-f)
identification division.
program-id. Program1.

environment division.
configuration section.

class java-tprestint as "$java$TPrestInter"
class lire-tprestint as "$java$LireTPrestInt".

data division.
working-storage section.

01 obj-lire-tprest-int object reference.
01 tprest-int-struct.
03 numero-employeur pic 9(3).

01 x1 pic s9(18) comp-5.
01 x2 pic s9(18) comp-5.
01 x3 pic s9(18) comp-5.

01 x pic x(80).

procedure division.

display "Test Cobol <-> Java".

invoke java-tprestint "new" returning obj-java-tprestint.

invoke obj-java-tprestint "getNoEmployeur" returning x1.
exhibit named x1.

move 987 to x1.
invoke obj-java-tprestint "setNoEmployeur" using x1.

invoke lire-tprestint "new" returning obj-lire-tprest-int.

invoke obj-lire-tprest-int "getObject" returning tprest-int-struct.

exhibit named numero-employeur.


end program Program1.

The call to method "getObject" fails with the following exception:

Exception 65538 not trapped by the class javaexceptionmanager.

Description: "Java runtime exception"

Method 'getObject' with signature Ljava/lang/String; not found

Thanks in advance for your help.

Guy Fokou

2 Replies
Micro Focus Contributor
Micro Focus Contributor

RE: Receiving Java custom record in procedural cobol

What version of Visual COBOL are you using?

In the more recent versions of Visual COBOL it is not necessary to use the class repository. You could code as follows:

01 objLireTPrestInt type LireTPrestInt.

01 objTPrestInter type TPrestInter.

In your code:

set objLireTPrestInt to new LireTPrestInt.

set obj-lire-tprest-int  to new objLireTPrestInt::getObject()

Absent Member.
Absent Member.

RE: Receiving Java custom record in procedural cobol

Mike, this looks like native OO COBOL rather than COBOL JVM.

Guy, would compiling to COBOL JVM be an option for you? Integration between COBOL and Java is considerably easier if you can compile you COBOL code directly to Java byte code using Visual COBOL.

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.