Previous Topic Next topic Print topic


CobolNational Class

Restriction: This applies to native code only.

The CobolNational Java class enables you to create UTF-16 strings that can be passed to a COBOL PIC N(...) usage is national field.

For example, the following COBOL program, hellonat, receives the string "Hello From Java" into a data item defined as PIC N(40) USAGE IS NATIONAL:

 $set unicode(portable)
  working-storage section.
  linkage section.
  01 lnk-natstring   pic n(40) usage is national.
  procedure division using lnk-natstring.
      display "Java said to COBOL [" lnk-natstring "]"
      move "Hello From Java" to lnk-natstring
      exit program returning 0.

The corresponding Java code passes the string "Hello From Java" to the COBOL program, hellonat:

CobolNational cobnat = 
	             new CobolNational("Hello From Java", 40);
RuntimeSystem.cobcall("hellonat", 
              new ParameterList().add(cobnat));
System.out.println(cobnat.toString());
Previous Topic Next topic Print topic