The following pair of programs show group items being used to interoperate between JVM COBOL and native COBOL.
Native COBOL:
program-id. NativeProgram as "NativeProgram". linkage section. 01 pets. 03 p1 pic xxx. 03 p2 pic xxx. 03 result pic x(6). procedure division. goback. entry "SwapStrings" using pets. display "p1='" p1 "' p2='" p2 "'" move p1 to result(4:3) move p2 to result(1:3) goback. end program NativeProgram.
JVM COBOL:
program-id. JVMProgram as "JVMProgram". 01 pets. 03 dog pic xxx value "dog". 03 cat pic xxx value "cat". 03 result pic x(6). 01 nat-ptr procedure-pointer. procedure division. set nat-ptr to entry “NativeProgram" display "" display "Calling native program" display "=======================" display "Pass in 2 strings: '" dog "' & '" cat "'" perform reset-all call "SwapStrings" using pets display "Native program swaps strings" display "result = '" result "'" display "" goback. reset-all section. move spaces to result . end program.