Java Program
import com.acucorp.acucobolgt.*; public static void main(String[] args) throws IOException { try{ CVM cvm = CVM.GET_INSTANCE(); cvm.setErrorsOut("/tmp/errfile"); cvm.setConfigFile("c:/myproject/config"); cvm.initialize(); CALL_OPTIONS co = new CALL_OPTIONS(); co.setOption("debug_method", "1"); int intParam = 1; Integer objInt = new Integer(intParam); byte byteParam = 'a'; Byte objByte = new Byte(byteParam); char charParam = 'b'; Character objChar = new Character(charParam); Object params[] = { objInt, objByte, objChar }; cvm.callProgram("TestJavaToCobol", params, co); cvm.cancelProgram("TestJavaToCobol"); objInt = (Integer)params[0]; objByte = (Byte)params[1]; objChar = (Character)params[2]; System.out.println("COBOL changed value to " + objInt.intValue()); System.out.println("COBOL changed value to " + objByte.byteValue(); System.out.println("COBOL changed value to " + objChar.charValue()); cvm.shutdown(); } catch (Exception e){ e.printStackTrace(); } }
COBOL Program
identification division. program-id. TestJavaToCobol. data division. working-storage section. COPY "java.def". 01 status-val pic 9(02) value zero. linkage section. 01 integer-parameter usage is signed-int. 01 byte-parameter pic x. 01 char-parameter pic x. procedure division using integer-parameter, byte-parameter, char-parameter. main-logic. move 3 to integer-parameter. move "d" to byte-parameter. move "e" to char-parameter. exit program.