Skip to main content

I'm looking for a definitive way to solve a problem with String values which get garbled when  they are passed to COBOL via CCI IndexedRecord.

Is Pointer the only class with which we can have the String values passed to COBOL programs encoded during the process performed by the implementation of CCI? Pointer does not seem to be able to handle a large string value as per Documentation. The length of the strings we are deling with are very large and PIC X(99) is not suffice. Does anybody have clue? 

I'm looking for a definitive way to solve a problem with String values which get garbled when  they are passed to COBOL via CCI IndexedRecord.

Is Pointer the only class with which we can have the String values passed to COBOL programs encoded during the process performed by the implementation of CCI? Pointer does not seem to be able to handle a large string value as per Documentation. The length of the strings we are deling with are very large and PIC X(99) is not suffice. Does anybody have clue? 

You can definately pass a string larger than PIC X(99) to COBOL using the Pointer class.

It is basically just a wrapper class that holds the actual address of the string along with its length.

There are several methods that you can use to pass a string from Java to COBOL including Pointer, mfjstring data type, COBOLNational class, CustomRecord class or by using JNI.

Please take a look at the product documentation for Handling Strings from a Java program for examples of each.

Thanks.

 


I'm looking for a definitive way to solve a problem with String values which get garbled when  they are passed to COBOL via CCI IndexedRecord.

Is Pointer the only class with which we can have the String values passed to COBOL programs encoded during the process performed by the implementation of CCI? Pointer does not seem to be able to handle a large string value as per Documentation. The length of the strings we are deling with are very large and PIC X(99) is not suffice. Does anybody have clue? 

Hi, Chris

I appreciate your attention and quick response.

The reference under Bookshelf>Java and Cobol> 6. Java Data Types  informs that  Pointer is equivalent to PIC X(99) so I think  I am misunderstanding what is depicted in the table.  In more straight forward way, my question is whether or not passing regular Java String is viable if explicit character encoding is necessary when it is passed to COBOL program.  

Thank you very much.

Haruhiko Nishi


I'm looking for a definitive way to solve a problem with String values which get garbled when  they are passed to COBOL via CCI IndexedRecord.

Is Pointer the only class with which we can have the String values passed to COBOL programs encoded during the process performed by the implementation of CCI? Pointer does not seem to be able to handle a large string value as per Documentation. The length of the strings we are deling with are very large and PIC X(99) is not suffice. Does anybody have clue? 

Yes, that documentation for the equivalent COBOL data type should really be PIC X(n) instead of the specific PIC X(99) where (n) = size of the string that you are passing. PIC X(99) is supposed to just be an example of what you could pass.

The Pointer class handles the encoding itself by either using Java’s default encoding or one specified in the extra parameters of the constructor for the Pointer class itself eg: Pointer(StringBuffer, String encodingName etc..) See documentation here:

If you choose to use a non-default encoding then the COBOL program must match it too.
For example using UTF-16 and receiving it as a “pic x(..)” would result in a meaningless conversion.

If this is the case then you might want to consider using the “CobolNational” class with “pic n(..)”, instead.

We do have a question for you though.

In what manner are you currently using the Java-->COBOL interface?
Are you running the COBOL application under Enterprise Server and using the J2EE connector architecture or are you simply calling COBOL from Java using the cobcall methods?

Thanks.


I'm looking for a definitive way to solve a problem with String values which get garbled when  they are passed to COBOL via CCI IndexedRecord.

Is Pointer the only class with which we can have the String values passed to COBOL programs encoded during the process performed by the implementation of CCI? Pointer does not seem to be able to handle a large string value as per Documentation. The length of the strings we are deling with are very large and PIC X(99) is not suffice. Does anybody have clue? 

Hi Chris,

Thank you again for your very concise answer and it is very helpful.

We are using auto generated EJB version that connects to Enterprise Server using J2EE connector.

The default encoding for the environment that uses the generated EJB is UTF-8, whereas the encoding for the Enterprise Server environment  is SJIS. The aforementioned string value represents some large text and is padded with spaces  up to a fixed length allotted for legacy 2 byte character encodings.

The reason we are trying to explicitly encode the string value is that there are characters available only in MS932 character set. MS932 is a subset of SJIS, and it is what generally used for Japanese Microsoft Windows OS environment. When String.getBytes() is performed on Enterprise Server environment, whose OS default encoding is set to SJIS, those characters extended by MS932 are replaced with ? symbol. So the workaround we had to take was to explicitly specify the MS932 encoding. We know that the OS default encoding is SJIS and therefore the characters may not be displayed within the system, however it is not so much of concern as long as the code pages for those characters stay.  

So if we could use the Pointer to handle the string, which of the following should be used?

The generated EJB uses BY_REFERENCE for all of the setArgument method for each of the filed passed to COBOL program, regardless of the Java type, but we had to change it to BY_VALUE, if we wanted to use Pointer, otherwise EOFException gets thrown.

  com.microfocus.cobol.RuntimeProperties.BY_REFERENCE

  com.microfocus.cobol.RuntimeProperties.BY_VALUE

  com.microfocus.cobol.RuntimeProperties.OUTPUT_ONLY

  com.microfocus.cobol.RuntimeProperties.BY_CONTENT

Thank you,

You are so helpful.

javascript:void(0);

Haruhiko Nishi


I'm looking for a definitive way to solve a problem with String values which get garbled when  they are passed to COBOL via CCI IndexedRecord.

Is Pointer the only class with which we can have the String values passed to COBOL programs encoded during the process performed by the implementation of CCI? Pointer does not seem to be able to handle a large string value as per Documentation. The length of the strings we are deling with are very large and PIC X(99) is not suffice. Does anybody have clue? 

The following reply is from development:

---------

Why not send a byte[]

So, on the java side, they can do byte[] toBeSEntToES = StringName.getBytes(encodingName);

The logic for BY_REFERENCE and BY_VALUE in generated code is if it is just INPUT, it is BY_VALUE. If it is I/O, it is BY_REFERENCE.


I'm looking for a definitive way to solve a problem with String values which get garbled when  they are passed to COBOL via CCI IndexedRecord.

Is Pointer the only class with which we can have the String values passed to COBOL programs encoded during the process performed by the implementation of CCI? Pointer does not seem to be able to handle a large string value as per Documentation. The length of the strings we are deling with are very large and PIC X(99) is not suffice. Does anybody have clue? 

Hi, Chris,

Passing the byte[] as suggested by your development team has cause the following Exception to be thrown:

"608 Unknown external data type executing XXX," where XXX representes the name of the method that was executed.

As per the documentation, byte[] is not one of the supported data type, I believe.

Nonetheless, we all appreciate your support and your help has been very helpful to us.

Thank you,

Haruhiko Nishi


I'm looking for a definitive way to solve a problem with String values which get garbled when  they are passed to COBOL via CCI IndexedRecord.

Is Pointer the only class with which we can have the String values passed to COBOL programs encoded during the process performed by the implementation of CCI? Pointer does not seem to be able to handle a large string value as per Documentation. The length of the strings we are deling with are very large and PIC X(99) is not suffice. Does anybody have clue? 

In what application server are you running your J2EE?

Is this perhaps on JBoss 4/ 5 ?


I'm looking for a definitive way to solve a problem with String values which get garbled when  they are passed to COBOL via CCI IndexedRecord.

Is Pointer the only class with which we can have the String values passed to COBOL programs encoded during the process performed by the implementation of CCI? Pointer does not seem to be able to handle a large string value as per Documentation. The length of the strings we are deling with are very large and PIC X(99) is not suffice. Does anybody have clue? 

That is exactly what we use. We use JBoss 5. Is there any compatibility issues that have been acknowledged by your development team?  


I'm looking for a definitive way to solve a problem with String values which get garbled when  they are passed to COBOL via CCI IndexedRecord.

Is Pointer the only class with which we can have the String values passed to COBOL programs encoded during the process performed by the implementation of CCI? Pointer does not seem to be able to handle a large string value as per Documentation. The length of the strings we are deling with are very large and PIC X(99) is not suffice. Does anybody have clue? 

Development states that the error message that you are experiencing is what you would see if JBoss is not setup correctly to work with Enterprise Server.

Please check the following settings:

JBoss 5.1 Setup Instructions

Directory: server/default/conf

File: jboss-service.xml

CallByValue -> true

Directory: server/default/deployers/jbossweb.deployer\\META-INF

File: war-deployers-jboss-beans.xml

java2ClassLoadingCompliance -> true

Directory: server/default/deployers/

File: ear-deployer-jboss-beans.xml

CallByValue -> true

isolated -> false

 

Thanks.


I'm looking for a definitive way to solve a problem with String values which get garbled when  they are passed to COBOL via CCI IndexedRecord.

Is Pointer the only class with which we can have the String values passed to COBOL programs encoded during the process performed by the implementation of CCI? Pointer does not seem to be able to handle a large string value as per Documentation. The length of the strings we are deling with are very large and PIC X(99) is not suffice. Does anybody have clue? 

Hi, Chris

Thank you for this valuable information. I'll forward this to our team.

We sincerely  appreciate your support.

Thank you.