I have a RPGLE program which will call a Java program. The Java program will connect to a TCP server and get the ASCII data back.
I print the data in Java - it is ASCII value. And I use below command to set the value to a variable in RPGLE.
Code: Select all
* Prototype for Java String Object - get bytes method
D getBytes PR 2048A ExtProc(*JAVA:
D 'java.lang.String':
D 'getBytes')
D Varying
*
d l1rcvmsg S 2048A
/free
$rcvMsgStr = receive(TCPClient_);
l1rcvmsg = getBytes( $rcvMsgStr );
/end-free
It is because the auto conversion has issue.
The auto conversion will convert my data wrongly. For example the ASCII Hex is: 31 32 36 09 40 D0 10
The auto conversion will convert it to: F1 F2 F6 05 7C 0E FE, where the last byte (D0 10) is wrong. the excepted value should be: F1 F2 F6 05 7C 9F 10
From IBM document/Internet, looks like getBytes will convert the data to EBCDIC. My section is set CCSID 65535 and I have tried to set `l1rcvmsg` to CCSID(1208) etc.
Also I try `String_getUCS2` in post https://www.scottklement.com/forums/viewtopic.php?t=76
Nothing works.
IBM document said I should use JNI if i do not want the auto conversion.
I raise my query and want to check if any other way to resolve the issue without JNI.
Thank you all in advance.
Information about JNI:
- https://www.ibm.com/docs/en/i/7.3?topic ... jni-coding
- https://www.ibm.com/docs/en/i/7.3?topic ... prototypes