In general:
The compiler usually converts parameters in the calling program to the appropriate type, by examining the target method signature. This signature is available if the method is in the same source module as the calling program or in a module identified by the ILSOURCE directive or in an assembly identified by an ILREF directive.
Where the called program is not known at compile time or not available until run time, the calling program sets up parameter types based on only the data items in the CALL statement. At run time the types of the parameters might not match those in the target method and this causes the .NET CLR or JVM to raise an exception because it can't convert the data. You can avoid this by specifying the NOILNATIVE directive for both the calling and the called program.
>>-.----.---ILNATIVE---------->< | | +-NO-+
None
Default: | ILNATIVE |
IDE equivalent: | None. You can specify ILNATIVE as an additional Compiler directive under Project > Properties > COBOL |
The following programs demonstrate a case for compiling with NOILNATIVE:
cmain.cbl
01 ws-data pic 9(4) comp-5. procedure division. call “csub” using ws-data.
csub.cbl
linkage section. 01 ls-data. 03 ls-value pic 9(4) comp-5. procedure division using ls-data. move 100 to ls-value. exit program.
Compile the two programs independently, with the default setting of ILNATIVE, using commands such as:
cobol cmain ilgen; cobol csub ilgen(sub);
When you run the program cmain, an exception is raised at run time due to the different types of the ws-data and ls-data data items.
However, if you specify NOILNATIVE directive for both programs, as follows, both data items will be represented with the same type and so the argument will be successfully passed to the subprogram.
cobol cmain ilgen noilnative; cobol csub ilgen(sub) noilnative;
Comments:
A COBOL data item that is represented as a managed primitive performs significantly better than one that isn't. However, there are some situations where using IL native types is not suitable, such as when the call arguments do not match in dynamic calls, or when your program relies on the DEFAULTBYTE Compiler directive initializing an item that will be exposed as an IL native type.
You can avoid these problems by specifying the NOILNATIVE directive when compiling your program.