Skip to main content

How to pass a string buffer from cobol to java as Byte[]

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

To pass a structure like this:

01   LINKVARS.

    03  VAR1             PIC X(02).

    03  VAR2.

       05 VAR3           PIC X(10).

from COBOL to Java but to also  send it as a Byte[] type instead of a string.  Is there some way to do this?

Resolution:

You can't pass a record structure directly from COBOL to a Java method which is expecting a byte array, as there is no mapping for that within the Object COBOL runtime support.  However, we do have a means of creating arrays using the jarray class.

If you create a one dimensional byte array using the jarray class, the getData/commitData methods can then be used to copy a COBOL buffer into it.  That jarray can then be passed to the Java method that expects the byte array as a parameter.

Old KB# 5750

0 replies

Be the first to reply!