Highlighted
Absent Member.
Absent Member.
812 views

[archive] Java and Cobol Data Types

[Migrated content. Thread originally posted on 10 October 2005]

Hi,

I am looking at at java calling cobol solution for creating a web service in java that would do a call to a cobol program to read data and use existing business rule's.
The problem I am having is with the linkage section in the cobol program. How do you define Pic X variables in java. IE Pic x(200)
would be represented by a string in java, we seem to be getting linkage errors as the size of a java string is dynamic, I have read in the documentation of version 7 that you can switch off linkage checking but is this the route I want to go, is there another alternative to define the variables in java.
0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Java and Cobol Data Types

I am not a Java expert, from what I understand you can define actual string sizes in java, it is difficult and you might not get what you expect.

For interoperating with Java ACUCOBOL-GT provides linkage signatures
co.setOption("linkage_signature", "X200");

When using a Java string and filling it with 5 bytes, the linkage signature pads out the string to match the size of the linkage data item. This way you can be sure that you are receiving from java what your COBOL program expects (whether the data is being passed from java or a COBOL program).

I hope this helps.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Java and Cobol Data Types

Hi,

Forgive my ignorance but what if there are multiple linkage items in the call.
eg:

Java
====
string WhatToDo = "Read"; //10 chars
string CodeToRead = "01235"; //10 chars
string ReturnData; // 50 chars will be possibly returned

cvm.SetOption("linkage_signature","X10")
// surely this option can only apply to 1 linkage item and not multiple items


Cobol
=====
LINKAGE SECTION.

77 WhatToDo Pic X(10).
77 CodeToRead Pic X(10).
77 ReturnData Pic X(50)

thank you for the Help So Far.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Java and Cobol Data Types

The linkage signature would be:

cvm.SetOption("linkage_signature","X10X10X50")
0 Likes
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.